Class: LLM::Function::Return
- Inherits:
-
Struct
- Object
- Struct
- LLM::Function::Return
- Defined in:
- lib/llm/function.rb
Overview
LLM::Function::Return represents the result of a tool call.
In llm.rb, tool execution is not complete until the requested function is answered with a return object and that return is sent back through the context. This is the object that closes that loop.
The return carries:
-
the tool call ID
-
the tool name
-
the tool’s return value
That value is usually a ‘Hash`, but it can be any JSON-like structure your tool returns. `LLM::Function#call` produces one automatically, and `LLM::Function#cancel` produces one that represents a cancelled tool call.
You can also construct one directly when you need to intercept, scrub, or synthesize a tool return before sending it back to the model.
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Returns true when the return value represents an error.
- #interrupt! ⇒ nil (also: #cancel!)
-
#to_h ⇒ Hash
Returns a Hash representation of Return.
- #to_json ⇒ String
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
72 73 74 |
# File 'lib/llm/function.rb', line 72 def id @id end |
#name ⇒ Object
Returns the value of attribute name
72 73 74 |
# File 'lib/llm/function.rb', line 72 def name @name end |
#value ⇒ Object
Returns the value of attribute value
72 73 74 |
# File 'lib/llm/function.rb', line 72 def value @value end |
Instance Method Details
#error? ⇒ Boolean
Returns true when the return value represents an error.
76 77 78 |
# File 'lib/llm/function.rb', line 76 def error? Hash === value && value[:error] == true end |
#interrupt! ⇒ nil Also known as: cancel!
95 96 97 |
# File 'lib/llm/function.rb', line 95 def interrupt! nil end |
#to_h ⇒ Hash
Returns a Hash representation of LLM::Function::Return
83 84 85 |
# File 'lib/llm/function.rb', line 83 def to_h {id:, name:, value:} end |