fix: invalid json format (#2531)
This commit is contained in:
@@ -157,7 +157,7 @@ M.func = vim.schedule_wrap(function(input, opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local curl_cmd_str = table.concat(curl_cmd, " ")
|
local curl_cmd_str = table.concat(curl_cmd, " ")
|
||||||
local error_hint = curl_error_map[result.code] or "curl exited with code " .. result.code
|
local error_hint = curl_error_map[result.code] or ("curl exited with code " .. result.code)
|
||||||
local full_error = "curl command failed: "
|
local full_error = "curl command failed: "
|
||||||
.. error_hint
|
.. error_hint
|
||||||
.. "\n"
|
.. "\n"
|
||||||
|
|||||||
@@ -276,7 +276,11 @@ function M:parse_response(ctx, data_stream, event_state, opts)
|
|||||||
end
|
end
|
||||||
elseif content_block.type == "tool_use" then
|
elseif content_block.type == "tool_use" then
|
||||||
if opts.on_messages_add then
|
if opts.on_messages_add then
|
||||||
local complete_json = vim.json.decode(content_block.input_json)
|
local ok_, complete_json = pcall(vim.json.decode, content_block.input_json)
|
||||||
|
if not ok_ then
|
||||||
|
Utils.warn("Failed to parse tool_use input_json: " .. content_block.input_json)
|
||||||
|
return
|
||||||
|
end
|
||||||
local msg = new_assistant_message({
|
local msg = new_assistant_message({
|
||||||
type = "tool_use",
|
type = "tool_use",
|
||||||
name = content_block.name,
|
name = content_block.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user