2023-12-18 20:04:15 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi
|
|
|
|
module Automation
|
|
|
|
AVAILABLE_MODELS = [
|
|
|
|
{ id: "gpt-4-turbo", name: "discourse_automation.ai_models.gpt_4_turbo" },
|
|
|
|
{ id: "gpt-4", name: "discourse_automation.ai_models.gpt_4" },
|
2024-01-25 09:56:28 -05:00
|
|
|
{ id: "gpt-3.5-turbo", name: "discourse_automation.ai_models.gpt_3_5_turbo" },
|
2023-12-18 20:04:15 -05:00
|
|
|
{ id: "gemini-pro", name: "discourse_automation.ai_models.gemini_pro" },
|
2024-04-17 01:37:19 -04:00
|
|
|
{ id: "gemini-1.5-pro", name: "discourse_automation.ai_models.gemini_1_5_pro" },
|
2024-03-20 20:32:35 -04:00
|
|
|
{ id: "claude-2", name: "discourse_automation.ai_models.claude_2" },
|
2024-03-05 14:04:37 -05:00
|
|
|
{ id: "claude-3-sonnet", name: "discourse_automation.ai_models.claude_3_sonnet" },
|
|
|
|
{ id: "claude-3-opus", name: "discourse_automation.ai_models.claude_3_opus" },
|
2024-04-11 08:50:46 -04:00
|
|
|
{ id: "claude-3-haiku", name: "discourse_automation.ai_models.claude_3_haiku" },
|
|
|
|
{
|
|
|
|
id: "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
|
|
|
name: "discourse_automation.ai_models.mixtral_8x7b_instruct_v0_1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "mistralai/Mistral-7B-Instruct-v0.2",
|
|
|
|
name: "discourse_automation.ai_models.mistral_7b_instruct_v0_2",
|
|
|
|
},
|
2024-04-12 00:46:58 -04:00
|
|
|
{ id: "command-r", name: "discourse_automation.ai_models.command_r" },
|
|
|
|
{ id: "command-r-plus", name: "discourse_automation.ai_models.command_r_plus" },
|
2023-12-18 20:04:15 -05:00
|
|
|
]
|
2024-03-20 20:32:35 -04:00
|
|
|
|
|
|
|
def self.translate_model(model)
|
2024-04-17 01:37:19 -04:00
|
|
|
return "google:#{model}" if model.start_with? "gemini"
|
2024-03-20 20:32:35 -04:00
|
|
|
return "open_ai:#{model}" if model.start_with? "gpt"
|
2024-04-12 00:46:58 -04:00
|
|
|
return "cohere:#{model}" if model.start_with? "command"
|
2024-03-20 20:32:35 -04:00
|
|
|
|
|
|
|
if model.start_with? "claude"
|
|
|
|
if DiscourseAi::Completions::Endpoints::AwsBedrock.correctly_configured?(model)
|
|
|
|
return "aws_bedrock:#{model}"
|
|
|
|
else
|
|
|
|
return "anthropic:#{model}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-04-11 08:50:46 -04:00
|
|
|
if model.start_with?("mistral")
|
|
|
|
if DiscourseAi::Completions::Endpoints::Vllm.correctly_configured?(model)
|
|
|
|
return "vllm:#{model}"
|
|
|
|
else
|
|
|
|
return "hugging_face:#{model}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-03-20 20:32:35 -04:00
|
|
|
raise "Unknown model #{model}"
|
|
|
|
end
|
2023-12-18 20:04:15 -05:00
|
|
|
end
|
|
|
|
end
|