FEATURE: Support for GPT-4 in AI Helper module (#29)

This commit is contained in:
Rafael dos Santos Silva 2023-03-28 23:22:34 -03:00 committed by GitHub
parent 45950f1bb4
commit b942a18298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -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"

View File

@ -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: ""

View File

@ -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 =