Revert "refactor: message content (#1424)" (#1442)

This reverts commit ae8497faf1.
This commit is contained in:
yetone
2025-03-01 13:25:51 +08:00
committed by GitHub
parent 5bb055795f
commit 0d592f440c
10 changed files with 124 additions and 186 deletions

View File

@@ -392,7 +392,6 @@ local function transform_result_content(selected_files, result_content, prev_fil
elseif line_content == "<think>" then
is_thinking = true
last_think_tag_start_line = i
last_think_tag_end_line = 0
elseif line_content == "</think>" then
is_thinking = false
last_think_tag_end_line = i
@@ -2357,7 +2356,6 @@ function Sidebar:create_input_container(opts)
end
end
---@type AvanteLLMMessage[]
local history_messages = {}
for i = #chat_history, 1, -1 do
local entry = chat_history[i]
@@ -2370,9 +2368,11 @@ function Sidebar:create_input_container(opts)
then
break
end
local assistant_content = {}
table.insert(assistant_content, { type = "text", text = Utils.trim_think_content(entry.original_response) })
table.insert(history_messages, 1, { role = "assistant", content = assistant_content })
table.insert(
history_messages,
1,
{ role = "assistant", content = Utils.trim_think_content(entry.original_response) }
)
local user_content = ""
if entry.selected_file ~= nil then
user_content = user_content .. "SELECTED FILE: " .. entry.selected_file.filepath .. "\n\n"
@@ -2386,18 +2386,9 @@ function Sidebar:create_input_container(opts)
.. "\n```\n\n"
end
user_content = user_content .. "USER PROMPT:\n\n" .. entry.request
table.insert(history_messages, 1, {
role = "user",
content = {
{
type = "text",
text = user_content,
},
},
})
table.insert(history_messages, 1, { role = "user", content = user_content })
end
---@type AvanteGeneratePromptsOptions
return {
ask = opts.ask or true,
project_context = vim.json.encode(project_context),