chore(clipboard): separate logic to save as base64 and files (#329)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-28 11:52:12 -04:00
committed by GitHub
parent 2c450b1da3
commit 755c15c0bd
9 changed files with 89 additions and 9 deletions

View File

@@ -61,18 +61,21 @@ M.get_user_message = function(opts)
end
M.parse_message = function(opts)
local user_content = {}
---@type string | OpenAIMessage[]
local user_content
if Config.behaviour.support_paste_from_clipboard and Clipboard.has_content() then
user_content = {}
table.insert(user_content, {
type = "image_url",
image_url = {
url = "data:image/png;base64," .. Clipboard.get_content(),
url = "data:image/png;base64," .. Clipboard.get_base64_content(),
},
})
table.insert(user_content, { type = "text", text = M.get_user_message(opts) })
else
user_content = M.get_user_message(opts)
end
table.insert(user_content, { type = "text", text = M.get_user_message(opts) })
return {
{ role = "system", content = opts.system_prompt },
{ role = "user", content = user_content },