Class: LittleGhost::Content::ToolResult
- Inherits:
-
Data
- Object
- Data
- LittleGhost::Content::ToolResult
- 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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tool_use_id ⇒ Object
readonly
Returns the value of attribute tool_use_id.
Instance Method Summary collapse
-
#initialize(tool_use_id:, content:, status:) ⇒ ToolResult
constructor
A new instance of ToolResult.
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
#content ⇒ Object (readonly)
Returns the value of attribute content
46 47 48 |
# File 'lib/little_ghost/content.rb', line 46 def content @content end |
#status ⇒ Object (readonly)
Returns the value of attribute status
46 47 48 |
# File 'lib/little_ghost/content.rb', line 46 def status @status end |
#tool_use_id ⇒ Object (readonly)
Returns the value of attribute tool_use_id
46 47 48 |
# File 'lib/little_ghost/content.rb', line 46 def tool_use_id @tool_use_id end |