feat(openai): support pasting image from clipboard (#280)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
cf68572494
commit
971e61b2c8
@ -1,5 +1,6 @@
|
|||||||
local Utils = require("avante.utils")
|
local Utils = require("avante.utils")
|
||||||
local Config = require("avante.config")
|
local Config = require("avante.config")
|
||||||
|
local Clipboard = require("avante.clipboard")
|
||||||
local P = require("avante.providers")
|
local P = require("avante.providers")
|
||||||
|
|
||||||
---@class OpenAIChatResponse
|
---@class OpenAIChatResponse
|
||||||
@ -55,9 +56,21 @@ M.parse_message = function(opts)
|
|||||||
.. opts.question
|
.. opts.question
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local user_content = {}
|
||||||
|
if Config.behaviour.support_paste_from_clipboard and Clipboard.has_content() then
|
||||||
|
table.insert(user_content, {
|
||||||
|
type = "image_url",
|
||||||
|
image_url = {
|
||||||
|
url = "data:image/png;base64," .. Clipboard.get_content(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(user_content, { type = "text", text = user_prompt })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{ role = "system", content = opts.system_prompt },
|
{ role = "system", content = opts.system_prompt },
|
||||||
{ role = "user", content = user_prompt },
|
{ role = "user", content = user_content },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user