refactor: message content (#1424)

This commit is contained in:
yetone
2025-02-28 14:43:39 +08:00
committed by GitHub
parent ebadba7420
commit ae8497faf1
10 changed files with 187 additions and 125 deletions

View File

@@ -33,9 +33,15 @@ function M.parse_messages(opts)
end
end
prev_role = role
table.insert(contents, { role = M.role_map[role] or role, parts = {
{ text = message.content },
} })
local parts = {}
for _, item in ipairs(message.content) do
if type(item) == "string" then
table.insert(parts, { text = item })
elseif item.type == "text" then
table.insert(parts, { text = item.text })
end
end
table.insert(contents, { role = M.role_map[role] or role, parts = parts })
end)
if Clipboard.support_paste_image() and opts.image_paths then