Class: Legion::LLM::Types::Chunk
- Inherits:
-
Data
- Object
- Data
- Legion::LLM::Types::Chunk
- Defined in:
- lib/legion/llm/types/chunk.rb
Constant Summary collapse
- CHUNK_TYPES =
%i[content_delta thinking_delta tool_call_delta usage done error].freeze
Instance Attribute Summary collapse
-
#content_block_index ⇒ Object
readonly
Returns the value of attribute content_block_index.
-
#conversation_id ⇒ Object
readonly
Returns the value of attribute conversation_id.
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#exchange_id ⇒ Object
readonly
Returns the value of attribute exchange_id.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#stop_reason ⇒ Object
readonly
Returns the value of attribute stop_reason.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#tool_call ⇒ Object
readonly
Returns the value of attribute tool_call.
-
#tracing ⇒ Object
readonly
Returns the value of attribute tracing.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Class Method Summary collapse
- .content_delta(delta:, request_id:, conversation_id: nil, exchange_id: nil, index: 0) ⇒ Object
- .done(request_id:, usage: nil, stop_reason: nil, conversation_id: nil, exchange_id: nil) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#content_block_index ⇒ Object (readonly)
Returns the value of attribute content_block_index
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def content_block_index @content_block_index end |
#conversation_id ⇒ Object (readonly)
Returns the value of attribute conversation_id
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def conversation_id @conversation_id end |
#delta ⇒ Object (readonly)
Returns the value of attribute delta
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def delta @delta end |
#exchange_id ⇒ Object (readonly)
Returns the value of attribute exchange_id
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def exchange_id @exchange_id end |
#index ⇒ Object (readonly)
Returns the value of attribute index
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def index @index end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def request_id @request_id end |
#stop_reason ⇒ Object (readonly)
Returns the value of attribute stop_reason
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def stop_reason @stop_reason end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def @timestamp end |
#tool_call ⇒ Object (readonly)
Returns the value of attribute tool_call
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def tool_call @tool_call end |
#tracing ⇒ Object (readonly)
Returns the value of attribute tracing
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def tracing @tracing end |
#type ⇒ Object (readonly)
Returns the value of attribute type
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def type @type end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage
6 7 8 |
# File 'lib/legion/llm/types/chunk.rb', line 6 def usage @usage end |
Class Method Details
.content_delta(delta:, request_id:, conversation_id: nil, exchange_id: nil, index: 0) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/legion/llm/types/chunk.rb', line 12 def self.content_delta(delta:, request_id:, conversation_id: nil, exchange_id: nil, index: 0) new(type: :content_delta, delta: delta, index: index, request_id: request_id, conversation_id: conversation_id, exchange_id: exchange_id, content_block_index: nil, tool_call: nil, usage: nil, stop_reason: nil, tracing: nil, timestamp: Time.now) end |
.done(request_id:, usage: nil, stop_reason: nil, conversation_id: nil, exchange_id: nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/legion/llm/types/chunk.rb', line 20 def self.done(request_id:, usage: nil, stop_reason: nil, conversation_id: nil, exchange_id: nil) new(type: :done, request_id: request_id, conversation_id: conversation_id, exchange_id: exchange_id, usage: usage, stop_reason: stop_reason, index: nil, content_block_index: nil, delta: nil, tool_call: nil, tracing: nil, timestamp: Time.now) end |
Instance Method Details
#content? ⇒ Boolean
28 29 30 |
# File 'lib/legion/llm/types/chunk.rb', line 28 def content? type == :content_delta end |
#done? ⇒ Boolean
32 33 34 |
# File 'lib/legion/llm/types/chunk.rb', line 32 def done? type == :done end |
#to_h ⇒ Object
36 37 38 |
# File 'lib/legion/llm/types/chunk.rb', line 36 def to_h super.compact end |