Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop adding separator when completing a partial assistant response #57

Merged
merged 2 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lua/model/core/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,17 @@ function M.run_chat(opts)
error('Chat prompt run() returned nil')
end

local seg = segment.create_segment_at(#buf_lines, 0)
local starter_separator = needs_nl(buf_lines) and '\n======\n' or '======\n'
local seg

local starter_seperator = needs_nl(buf_lines) and '\n======\n' or '======\n'
seg.add(starter_seperator)
local last_msg = parsed.contents.messages[#parsed.contents.messages]

if last_msg.role == 'user' then
seg = segment.create_segment_at(#buf_lines, 0)
seg.add(starter_separator)
else
seg = segment.create_segment_at(#buf_lines-1, #buf_lines[#buf_lines])
end

local sayer = juice.sayer()

Expand All @@ -271,7 +278,7 @@ function M.run_chat(opts)
sayer.finish()

if text then
seg.set_text(starter_seperator .. text .. '\n======\n')
seg.set_text((last_msg.role == 'user' and (starter_separator .. text) or text) .. '\n======\n')
else
seg.add('\n======\n')
end
Expand Down
Loading