Class: Agent::Sessions::Part
- Inherits:
-
Data
- Object
- Data
- Agent::Sessions::Part
- Defined in:
- lib/agent/sessions/part.rb
Overview
One piece of a message. type is the normalized vocabulary (design doc §5);
everything an agent said that this gem could not classify arrives as
:unknown rather than as an exception, and the message's raw still holds it.
text carries the readable content for :text, :thinking and :tool_result. name and call_id are tool plumbing, nil elsewhere. An :image part has neither — its URL or payload stays in raw, because normalizing an image would mean deciding whether to load it, and reading is stat-cheap by design.
Constant Summary collapse
- TYPES =
%i[text thinking tool_use tool_result image unknown].freeze
Instance Attribute Summary collapse
-
#call_id ⇒ Object
readonly
Returns the value of attribute call_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, text: nil, name: nil, call_id: nil) ⇒ Part
constructor
A new instance of Part.
Constructor Details
#initialize(type:, text: nil, name: nil, call_id: nil) ⇒ Part
Returns a new instance of Part.
14 15 16 17 18 19 |
# File 'lib/agent/sessions/part.rb', line 14 def initialize(type:, text: nil, name: nil, call_id: nil) types = self.class::TYPES raise ArgumentError, "part type #{type.inspect} must be one of #{types.join(", ")}" unless types.include?(type) super end |
Instance Attribute Details
#call_id ⇒ Object (readonly)
Returns the value of attribute call_id
13 14 15 |
# File 'lib/agent/sessions/part.rb', line 13 def call_id @call_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name
13 14 15 |
# File 'lib/agent/sessions/part.rb', line 13 def name @name end |
#text ⇒ Object (readonly)
Returns the value of attribute text
13 14 15 |
# File 'lib/agent/sessions/part.rb', line 13 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type
13 14 15 |
# File 'lib/agent/sessions/part.rb', line 13 def type @type end |