Class: LittleGhost::Content::ToolUse
- Inherits:
-
Data
- Object
- Data
- LittleGhost::Content::ToolUse
- 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
Describes one tool call requested by a provider-backed model.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(id:, name:, input:) ⇒ ToolUse
constructor
A new instance of ToolUse.
Constructor Details
#initialize(id:, name:, input:) ⇒ ToolUse
Returns a new instance of ToolUse.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/little_ghost/content.rb', line 33 def initialize(id:, name:, input:) id = String(id) name = String(name) raise ArgumentError, "tool use id is required" if id.empty? raise ArgumentError, "tool use name is required" if name.empty? raise ArgumentError, "tool use input must be an object" unless input.is_a?(Hash) super(id: id.to_s, name: name.to_s, input:) rescue TypeError raise ArgumentError, "tool use id and name must be strings" end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id
30 31 32 |
# File 'lib/little_ghost/content.rb', line 30 def id @id end |
#input ⇒ Object (readonly)
Returns the value of attribute input
30 31 32 |
# File 'lib/little_ghost/content.rb', line 30 def input @input end |
#name ⇒ Object (readonly)
Returns the value of attribute name
30 31 32 |
# File 'lib/little_ghost/content.rb', line 30 def name @name end |