Class: Agent::Sessions::Part

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(type:, text: nil, name: nil, call_id: nil) ⇒ Part

Returns a new instance of Part.

Raises:

  • (ArgumentError)


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_idObject (readonly)

Returns the value of attribute call_id

Returns:

  • (Object)

    the current value of call_id



13
14
15
# File 'lib/agent/sessions/part.rb', line 13

def call_id
  @call_id
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



13
14
15
# File 'lib/agent/sessions/part.rb', line 13

def name
  @name
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



13
14
15
# File 'lib/agent/sessions/part.rb', line 13

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



13
14
15
# File 'lib/agent/sessions/part.rb', line 13

def type
  @type
end