Skip to content

Expose persisted assistant message during streaming#823

Open
goianiense wants to merge 1 commit into
crmne:mainfrom
goianiense:feature/814-expose-persisted-message-during-streaming
Open

Expose persisted assistant message during streaming#823
goianiense wants to merge 1 commit into
crmne:mainfrom
goianiense:feature/814-expose-persisted-message-during-streaming

Conversation

@goianiense

Copy link
Copy Markdown

Summary

  • Add a public attr_reader :message on acts_as_chat models that exposes the assistant record currently being persisted during complete/ask (including across tool-flow turns).
  • Lets streaming blocks broadcast against the stable in-memory record without relying on messages.last, before_message capture, or private ivar access.
  • Update the chat UI generator job template and streaming docs to use the new reader.

Closes #814

Usage

chat.complete do |chunk|
  chat.message.broadcast_append_chunk(chunk.content) if chunk.content.present?
end

Test plan

  • Specs for chat.message nil before completion and set afterwards
  • Specs for chat.message available inside the streaming block
  • Specs for reassignment on tool-flow assistant turns
  • Generator job expectations updated and passing
  • CI green on this PR

Add a public attr_reader :message on acts_as_chat models so streaming
blocks can broadcast against the assistant record RubyLLM is currently
persisting, without relying on messages.last or private ivar access.

Closes crmne#814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Expose persisted assistant message during streaming

1 participant