fix: gemini content parts is nil (#1942)
This commit is contained in:
@@ -137,6 +137,7 @@ function M:parse_response(ctx, data_stream, _, opts)
|
|||||||
local candidate = json.candidates[1]
|
local candidate = json.candidates[1]
|
||||||
---@type AvanteLLMToolUse[]
|
---@type AvanteLLMToolUse[]
|
||||||
local tool_use_list = {}
|
local tool_use_list = {}
|
||||||
|
if candidate.content.parts ~= nil then
|
||||||
for _, part in ipairs(candidate.content.parts) do
|
for _, part in ipairs(candidate.content.parts) do
|
||||||
if part.text then
|
if part.text then
|
||||||
if opts.on_chunk then opts.on_chunk(part.text) end
|
if opts.on_chunk then opts.on_chunk(part.text) end
|
||||||
@@ -153,6 +154,7 @@ function M:parse_response(ctx, data_stream, _, opts)
|
|||||||
OpenAI:add_tool_use_message(tool_use, "generated", opts)
|
OpenAI:add_tool_use_message(tool_use, "generated", opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if candidate.finishReason and candidate.finishReason == "STOP" then
|
if candidate.finishReason and candidate.finishReason == "STOP" then
|
||||||
OpenAI:finish_pending_messages(ctx, opts)
|
OpenAI:finish_pending_messages(ctx, opts)
|
||||||
if #tool_use_list > 0 then
|
if #tool_use_list > 0 then
|
||||||
|
|||||||
Reference in New Issue
Block a user