fix: copilot tool histories (#1197)
This commit is contained in:
parent
1ec12907a2
commit
402c7f9665
@ -215,27 +215,30 @@ M.parse_messages = function(opts)
|
|||||||
vim
|
vim
|
||||||
.iter(opts.messages)
|
.iter(opts.messages)
|
||||||
:each(function(msg) table.insert(messages, { role = M.role_map[msg.role], content = msg.content }) end)
|
:each(function(msg) table.insert(messages, { role = M.role_map[msg.role], content = msg.content }) end)
|
||||||
if opts.tool_result then
|
|
||||||
|
if opts.tool_histories then
|
||||||
|
for _, tool_history in ipairs(opts.tool_histories) do
|
||||||
table.insert(messages, {
|
table.insert(messages, {
|
||||||
role = M.role_map["assistant"],
|
role = M.role_map["assistant"],
|
||||||
tool_calls = {
|
tool_calls = {
|
||||||
{
|
{
|
||||||
id = opts.tool_use.id,
|
id = tool_history.tool_use.id,
|
||||||
type = "function",
|
type = "function",
|
||||||
["function"] = {
|
["function"] = {
|
||||||
name = opts.tool_use.name,
|
name = tool_history.tool_use.name,
|
||||||
arguments = opts.tool_use.input_json,
|
arguments = tool_history.tool_use.input_json,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
local result_content = opts.tool_result.content or ""
|
local result_content = tool_history.tool_result.content or ""
|
||||||
table.insert(messages, {
|
table.insert(messages, {
|
||||||
role = "tool",
|
role = "tool",
|
||||||
tool_call_id = opts.tool_result.tool_use_id,
|
tool_call_id = tool_history.tool_result.tool_use_id,
|
||||||
content = opts.tool_result.is_error and "Error: " .. result_content or result_content,
|
content = tool_history.tool_result.is_error and "Error: " .. result_content or result_content,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return messages
|
return messages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user