feat: bedrock use tools (#1184)
This commit is contained in:
parent
3aaf7dad77
commit
e1125fca54
@ -32,6 +32,40 @@ M.parse_messages = function(opts)
|
||||
})
|
||||
end
|
||||
|
||||
if opts.tool_use then
|
||||
local msg = {
|
||||
role = "assistant",
|
||||
content = {},
|
||||
}
|
||||
if opts.response_content then
|
||||
msg.content[#msg.content + 1] = {
|
||||
type = "text",
|
||||
text = opts.response_content,
|
||||
}
|
||||
end
|
||||
msg.content[#msg.content + 1] = {
|
||||
type = "tool_use",
|
||||
id = opts.tool_use.id,
|
||||
name = opts.tool_use.name,
|
||||
input = vim.json.decode(opts.tool_use.input_json),
|
||||
}
|
||||
messages[#messages + 1] = msg
|
||||
end
|
||||
|
||||
if opts.tool_result then
|
||||
messages[#messages + 1] = {
|
||||
role = "user",
|
||||
content = {
|
||||
{
|
||||
type = "tool_result",
|
||||
tool_use_id = opts.tool_result.tool_use_id,
|
||||
content = opts.tool_result.content,
|
||||
is_error = opts.tool_result.is_error,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return messages
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user