fix: o1 model (#1992)
This commit is contained in:
@@ -694,6 +694,11 @@ local function insert_conflict_contents(bufnr, snippets)
|
||||
for _, snippet in ipairs(snippets) do
|
||||
local start_line, end_line = unpack(snippet.range)
|
||||
|
||||
local first_line_content = lines[start_line]
|
||||
local old_first_line_indentation = ""
|
||||
|
||||
if first_line_content then old_first_line_indentation = Utils.get_indentation(first_line_content) end
|
||||
|
||||
local result = {}
|
||||
table.insert(result, "<<<<<<< HEAD")
|
||||
for i = start_line, end_line do
|
||||
@@ -703,6 +708,14 @@ local function insert_conflict_contents(bufnr, snippets)
|
||||
|
||||
local snippet_lines = vim.split(snippet.content, "\n")
|
||||
|
||||
if #snippet_lines > 0 then
|
||||
local new_first_line_indentation = Utils.get_indentation(snippet_lines[1])
|
||||
if #old_first_line_indentation > #new_first_line_indentation then
|
||||
local line_indentation = old_first_line_indentation:sub(#new_first_line_indentation + 1)
|
||||
snippet_lines = vim.iter(snippet_lines):map(function(line) return line_indentation .. line end):totable()
|
||||
end
|
||||
end
|
||||
|
||||
vim.list_extend(result, snippet_lines)
|
||||
|
||||
table.insert(result, ">>>>>>> Snippet")
|
||||
@@ -1892,10 +1905,19 @@ function Sidebar:add_history_messages(messages)
|
||||
end
|
||||
self.chat_history.messages = history_messages
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
if self.chat_history.title == "untitled" and #messages > 0 then
|
||||
if
|
||||
self.chat_history.title == "untitled"
|
||||
and #messages > 0
|
||||
and messages[1].just_for_display ~= true
|
||||
and messages[1].state == "generated"
|
||||
then
|
||||
self.chat_history.title = "generating..."
|
||||
Llm.summarize_chat_thread_title(messages[1].message.content, function(title)
|
||||
self:reload_chat_history()
|
||||
if title then self.chat_history.title = title end
|
||||
if title then
|
||||
self.chat_history.title = title
|
||||
else
|
||||
self.chat_history.title = "untitled"
|
||||
end
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
end)
|
||||
end
|
||||
@@ -2371,14 +2393,7 @@ function Sidebar:create_input_container()
|
||||
if Config.behaviour.auto_apply_diff_after_generation then self:apply(false) end
|
||||
end, 0)
|
||||
|
||||
if self.chat_history.title == "untitled" then
|
||||
Llm.summarize_chat_thread_title(request, function(title)
|
||||
if title then self.chat_history.title = title end
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
end)
|
||||
else
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
end
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
end
|
||||
|
||||
if request and request ~= "" then
|
||||
@@ -2407,18 +2422,22 @@ function Sidebar:create_input_container()
|
||||
session_ctx = {},
|
||||
})
|
||||
|
||||
---@param dropped_history_messages avante.HistoryMessage[]
|
||||
local function on_memory_summarize(dropped_history_messages)
|
||||
---@param pending_compaction_history_messages avante.HistoryMessage[]
|
||||
local function on_memory_summarize(pending_compaction_history_messages)
|
||||
local history_memory = self.chat_history.memory
|
||||
Llm.summarize_memory(history_memory and history_memory.content, dropped_history_messages, function(memory)
|
||||
if memory then
|
||||
self.chat_history.memory = memory
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
stream_options.memory = memory.content
|
||||
Llm.summarize_memory(
|
||||
history_memory and history_memory.content,
|
||||
pending_compaction_history_messages,
|
||||
function(memory)
|
||||
if memory then
|
||||
self.chat_history.memory = memory
|
||||
Path.history.save(self.code.bufnr, self.chat_history)
|
||||
stream_options.memory = memory.content
|
||||
end
|
||||
stream_options.history_messages = self:get_history_messages_for_api()
|
||||
Llm.stream(stream_options)
|
||||
end
|
||||
stream_options.history_messages = self:get_history_messages_for_api()
|
||||
Llm.stream(stream_options)
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
stream_options.on_memory_summarize = on_memory_summarize
|
||||
|
||||
Reference in New Issue
Block a user