Skip to content

Commit

Permalink
fix(AG-178): fix gemini parsing multiple chained tool calls
Browse files Browse the repository at this point in the history
(cherry picked from commit 581571b)
  • Loading branch information
tysoekong authored and fffonion committed Nov 29, 2024
1 parent 0da322f commit 9ecbc3e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions kong/llm/drivers/gemini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,23 @@ local function from_gemini_chat_openai(response, model_info, route_type)
messages.model = model_info.name

elseif is_tool_content(response) then
messages.choices[1] = {
index = 0,
message = {
role = "assistant",
tool_calls = {},
},
}

local function_call_responses = response.candidates[1].content.parts
for i, v in ipairs(function_call_responses) do
messages.choices[i] = {
index = 0,
message = {
role = "assistant",
tool_calls = {
{
['function'] = {
name = v.functionCall.name,
arguments = cjson.encode(v.functionCall.args),
},
},
messages.choices[1].message.tool_calls[i] =
{
['function'] = {
name = v.functionCall.name,
arguments = cjson.encode(v.functionCall.args),
},
},
}
}
end
end

Expand Down

0 comments on commit 9ecbc3e

Please sign in to comment.