diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index fab5c71e..c46492c5 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -36,6 +36,7 @@ en: composer_ai_helper_enabled: "Enable the Composer's AI helper." ai_helper_allowed_groups: "Users on these groups will see the AI helper button in the composer." ai_helper_allowed_in_pm: "Enable the composer's AI helper in PMs." + ai_helper_model: "Model to use for the AI helper." ai_embeddings_enabled: "Enable the embeddings module." ai_embeddings_discourse_service_api_endpoint: "URL where the API is running for the embeddings module" diff --git a/config/settings.yml b/config/settings.yml index 4d9a10ea..4d7c2136 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -101,6 +101,12 @@ plugins: ai_helper_allowed_in_pm: default: false client: true + ai_helper_model: + default: gpt-3.5-turbo + type: enum + choices: + - gpt-3.5-turbo + - gpt-4 ai_embeddings_enabled: false ai_embeddings_discourse_service_api_endpoint: "" diff --git a/lib/shared/inference/openai_completions.rb b/lib/shared/inference/openai_completions.rb index 22439b6a..61f6b3c0 100644 --- a/lib/shared/inference/openai_completions.rb +++ b/lib/shared/inference/openai_completions.rb @@ -5,12 +5,14 @@ module ::DiscourseAi class OpenAiCompletions CompletionFailed = Class.new(StandardError) - def self.perform!(messages, model = "gpt-3.5-turbo") + def self.perform!(messages) headers = { "Authorization" => "Bearer #{SiteSetting.ai_openai_api_key}", "Content-Type" => "application/json", } + model = SiteSetting.ai_helper_model + connection_opts = { request: { write_timeout: 60, read_timeout: 60, open_timeout: 60 } } response =