mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 04:25:50 +08:00
Previously, sentiment and emotion classification only used configured classification model endpoints, which blocked sites that could not run those models. This change lets admins choose agent-backed LLM classifiers for sentiment and emotion while storing results under stable model keys so LLM changes do not force historic reclassification.
39 lines
992 B
Ruby
Vendored
39 lines
992 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Sentiment
|
|
class SentimentSiteSettingJsonSchema
|
|
def self.schema
|
|
@schema ||= {
|
|
type: "array",
|
|
items: {
|
|
type: "object",
|
|
format: "table",
|
|
title: "model",
|
|
properties: {
|
|
classification_type: {
|
|
type: "string",
|
|
enum: %w[sentiment emotion],
|
|
},
|
|
model_name: {
|
|
type: "string",
|
|
},
|
|
endpoint: {
|
|
type: "string",
|
|
},
|
|
api_key: {
|
|
type: "string",
|
|
},
|
|
},
|
|
required: %w[classification_type model_name endpoint api_key],
|
|
},
|
|
}
|
|
end
|
|
|
|
def self.values
|
|
return {} if SiteSetting.ai_sentiment_model_configs.blank?
|
|
JSON.parse(SiteSetting.ai_sentiment_model_configs, object_class: OpenStruct)
|
|
end
|
|
end
|
|
end
|
|
end
|