Class: LittleGhost::Content::ToolResult

Inherits:
Data
  • Object
show all
Includes:
Module.new do # :nodoc: def to_h = Content.serialize(self) def to_json(*arguments) = JSON.generate(to_h, *arguments) end
Defined in:
lib/little_ghost/content.rb,
lib/little_ghost/content.rb

Overview

Carries the model-facing result for one ToolUse. A successful result uses :success; a caller-safe failure uses :error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool_use_id:, content:, status:) ⇒ ToolResult

Returns a new instance of ToolResult.



49
50
51
52
53
54
55
56
57
58
# File 'lib/little_ghost/content.rb', line 49

def initialize(tool_use_id:, content:, status:)
  tool_use_id = String(tool_use_id)
  status = status.to_sym
  raise ArgumentError, "tool result id is required" if tool_use_id.empty?
  raise ArgumentError, "tool result status must be success or error" unless %i[success error].include?(status)

  super(tool_use_id: tool_use_id.freeze, content:, status:)
rescue TypeError, NoMethodError
  raise ArgumentError, "tool result id and status are invalid"
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



46
47
48
# File 'lib/little_ghost/content.rb', line 46

def content
  @content
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



46
47
48
# File 'lib/little_ghost/content.rb', line 46

def status
  @status
end

#tool_use_idObject (readonly)

Returns the value of attribute tool_use_id

Returns:

  • (Object)

    the current value of tool_use_id



46
47
48
# File 'lib/little_ghost/content.rb', line 46

def tool_use_id
  @tool_use_id
end