fix: filter out empty history (#794)
This commit is contained in:
parent
1e8abbf798
commit
5db2a0f92f
@ -1392,17 +1392,26 @@ function Sidebar:create_input(opts)
|
|||||||
|
|
||||||
local project_context = mentions.enable_project_context and RepoMap.get_repo_map(file_ext) or nil
|
local project_context = mentions.enable_project_context and RepoMap.get_repo_map(file_ext) or nil
|
||||||
|
|
||||||
local history_messages = vim.tbl_map(
|
local history_messages = vim
|
||||||
function(history)
|
.iter(chat_history)
|
||||||
return {
|
:filter(
|
||||||
{ role = "user", content = history.request },
|
function(history)
|
||||||
{ role = "assistant", content = history.original_response },
|
return history.request ~= nil
|
||||||
}
|
and history.original_response ~= nil
|
||||||
end,
|
and history.request ~= ""
|
||||||
chat_history
|
and history.original_response ~= ""
|
||||||
)
|
end
|
||||||
|
)
|
||||||
history_messages = vim.iter(history_messages):flatten():totable()
|
:map(
|
||||||
|
function(history)
|
||||||
|
return {
|
||||||
|
{ role = "user", content = history.request },
|
||||||
|
{ role = "assistant", content = history.original_response },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
)
|
||||||
|
:flatten()
|
||||||
|
:totable()
|
||||||
|
|
||||||
Llm.stream({
|
Llm.stream({
|
||||||
bufnr = self.code.bufnr,
|
bufnr = self.code.bufnr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user