Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions lib/ai_bot/playground.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def reply_to(post, custom_instructions: nil, &blk)
if stream_reply && !Discourse.redis.get(redis_stream_key)
cancel&.call
reply_post.update!(raw: reply, cooked: PrettyText.cook(reply))
break
end

if post_streamer
Expand Down
11 changes: 8 additions & 3 deletions lib/completions/endpoints/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,20 @@ def perform_completion!(

begin
cancelled = false
cancel = -> { cancelled = true }
if cancelled
cancel = -> do
cancelled = true
http.finish
break
end

break if cancelled

response.read_body do |chunk|
break if cancelled

response_raw << chunk

decode_chunk(chunk).each do |partial|
break if cancelled
partials_raw << partial.to_s
response_data << partial if partial.is_a?(String)
partials = [partial]
Expand Down