FEATURE: AI Bot Gemini support. (#402)
It also corrects the syntax around tool support, which was wrong. Gemini doesn't want us to include messages about previous tool invocations, so I had to shuffle around some code to send the response it generated from those invocations instead. For this, I created the "multi_turn" context, which bundles all the context involved in the interaction.
This commit is contained in:
+4
-1
@@ -125,6 +125,8 @@ module DiscourseAi
|
||||
"gpt-3.5-turbo-16k"
|
||||
when DiscourseAi::AiBot::EntryPoint::MIXTRAL_ID
|
||||
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
||||
when DiscourseAi::AiBot::EntryPoint::GEMINI_ID
|
||||
"gemini-pro"
|
||||
else
|
||||
nil
|
||||
end
|
||||
@@ -146,9 +148,10 @@ module DiscourseAi
|
||||
<summary>#{summary}</summary>
|
||||
<p>#{details}</p>
|
||||
</details>
|
||||
|
||||
HTML
|
||||
|
||||
placeholder << custom_raw << "\n" if custom_raw
|
||||
placeholder << custom_raw if custom_raw
|
||||
|
||||
placeholder
|
||||
end
|
||||
|
||||
@@ -10,12 +10,14 @@ module DiscourseAi
|
||||
CLAUDE_V2_ID = -112
|
||||
GPT4_TURBO_ID = -113
|
||||
MIXTRAL_ID = -114
|
||||
GEMINI_ID = -115
|
||||
BOTS = [
|
||||
[GPT4_ID, "gpt4_bot", "gpt-4"],
|
||||
[GPT3_5_TURBO_ID, "gpt3.5_bot", "gpt-3.5-turbo"],
|
||||
[CLAUDE_V2_ID, "claude_bot", "claude-2"],
|
||||
[GPT4_TURBO_ID, "gpt4t_bot", "gpt-4-turbo"],
|
||||
[MIXTRAL_ID, "mixtral_bot", "mixtral-8x7B-Instruct-V0.1"],
|
||||
[GEMINI_ID, "gemini_bot", "gemini-pro"],
|
||||
]
|
||||
|
||||
def self.map_bot_model_to_user_id(model_name)
|
||||
@@ -30,6 +32,8 @@ module DiscourseAi
|
||||
CLAUDE_V2_ID
|
||||
in "mixtral-8x7B-Instruct-V0.1"
|
||||
MIXTRAL_ID
|
||||
in "gemini-pro"
|
||||
GEMINI_ID
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -37,7 +37,6 @@ module DiscourseAi
|
||||
|
||||
result = []
|
||||
|
||||
first = true
|
||||
context.each do |raw, username, custom_prompt|
|
||||
custom_prompt_translation =
|
||||
Proc.new do |message|
|
||||
@@ -51,25 +50,22 @@ module DiscourseAi
|
||||
|
||||
custom_context[:name] = message[1] if custom_context[:type] != "assistant"
|
||||
|
||||
result << custom_context
|
||||
custom_context
|
||||
end
|
||||
end
|
||||
|
||||
if custom_prompt.present?
|
||||
if first
|
||||
custom_prompt.reverse_each(&custom_prompt_translation)
|
||||
first = false
|
||||
else
|
||||
tool_call_and_tool = custom_prompt.first(2)
|
||||
tool_call_and_tool.reverse_each(&custom_prompt_translation)
|
||||
end
|
||||
result << {
|
||||
type: "multi_turn",
|
||||
content: custom_prompt.reverse_each.map(&custom_prompt_translation).compact,
|
||||
}
|
||||
else
|
||||
context = {
|
||||
content: raw,
|
||||
type: (available_bot_usernames.include?(username) ? "assistant" : "user"),
|
||||
}
|
||||
|
||||
context[:name] = username if context[:type] == "user"
|
||||
context[:name] = clean_username(username) if context[:type] == "user"
|
||||
|
||||
result << context
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user