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]
|
||||
---@type AvanteLLMToolUse[]
|
||||
local tool_use_list = {}
|
||||
if candidate.content.parts ~= nil then
|
||||
for _, part in ipairs(candidate.content.parts) do
|
||||
if part.text then
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
if candidate.finishReason and candidate.finishReason == "STOP" then
|
||||
OpenAI:finish_pending_messages(ctx, opts)
|
||||
if #tool_use_list > 0 then
|
||||
|
||||
Reference in New Issue
Block a user