Class: RubyLLM::Chunk

Inherits:
Message show all
Defined in:
lib/ruby_llm/chunk.rb

Overview

A Chunk is one streamed fragment of an assistant response. Chunks are yielded to the block passed to Chat#ask or Chat#complete when streaming. A Chunk is a Message, so it responds to the same readers, but it holds only the data received in that part of the stream, such as a piece of content, partial tool calls, or the finish reason on the final chunk.

chat.ask "Write a haiku about Ruby" do |chunk|
print chunk.content
end

Constant Summary

Constants inherited from Message

Message::ROLES

Constants included from Support::Inspectable

Support::Inspectable::TRUNCATE_AT

Instance Attribute Summary

Attributes inherited from Message

#attachments, #citations, #content, #conversation, #finish_reason, #model, #model_info, #raw, #raw_content, #raw_reasoning, #role, #server_tool_calls, #thinking, #tool_call_id, #tool_calls

Method Summary

Methods inherited from Message

#cache_until_here, #cache_until_here?, #content_filtered?, #cost, #initialize, #max_tokens?, #parsed, #stopped?, #to_h, #tokens, #tool_call?, #tool_call_stop?, #tool_result?, #tool_results, #with_attachments, #without_thinking

Methods included from Accounting::Usage::Result

#ruby_llm_usage_entries, #ruby_llm_usage_entries=

Methods included from Support::Inspectable

#full_inspect, #inspect, #pretty_print

Constructor Details

This class inherits a constructor from RubyLLM::Message