feat: pasting image within buffer (#331)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
@@ -39,22 +39,22 @@ M.parse_message = function(opts)
|
||||
table.insert(message_content, selected_code_obj)
|
||||
end
|
||||
|
||||
table.insert(message_content, {
|
||||
type = "text",
|
||||
text = string.format("<question>%s</question>", opts.question),
|
||||
})
|
||||
|
||||
if Config.behaviour.support_paste_from_clipboard and Clipboard.has_content() then
|
||||
if Clipboard.support_paste_image() and opts.image_path then
|
||||
table.insert(message_content, {
|
||||
type = "image",
|
||||
source = {
|
||||
type = "base64",
|
||||
media_type = "image/png",
|
||||
data = Clipboard.get_base64_content(),
|
||||
data = Clipboard.get_base64_content(opts.image_path),
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(message_content, {
|
||||
type = "text",
|
||||
text = string.format("<question>%s</question>", opts.question),
|
||||
})
|
||||
|
||||
local user_prompt = opts.base_prompt
|
||||
|
||||
local user_prompt_obj = {
|
||||
|
||||
@@ -12,6 +12,7 @@ local Dressing = require("avante.ui.dressing")
|
||||
---@field base_prompt AvanteBasePrompt
|
||||
---@field system_prompt AvanteSystemPrompt
|
||||
---@field question string
|
||||
---@field image_path? string
|
||||
---@field code_lang string
|
||||
---@field code_content string
|
||||
---@field selected_code_content? string
|
||||
|
||||
@@ -63,12 +63,12 @@ end
|
||||
M.parse_message = function(opts)
|
||||
---@type string | OpenAIMessage[]
|
||||
local user_content
|
||||
if Config.behaviour.support_paste_from_clipboard and Clipboard.has_content() then
|
||||
if Config.behaviour.support_paste_from_clipboard and opts.image_path then
|
||||
user_content = {}
|
||||
table.insert(user_content, {
|
||||
type = "image_url",
|
||||
image_url = {
|
||||
url = "data:image/png;base64," .. Clipboard.get_base64_content(),
|
||||
url = "data:image/png;base64," .. Clipboard.get_base64_content(opts.image_path),
|
||||
},
|
||||
})
|
||||
table.insert(user_content, { type = "text", text = M.get_user_message(opts) })
|
||||
|
||||
Reference in New Issue
Block a user