Class: Truffle::Response
- Inherits:
-
Object
- Object
- Truffle::Response
- Defined in:
- lib/truffle/response.rb
Overview
A normalized response from a provider's chat call.
Every provider returns one of these regardless of its native wire format, so the agent loop never has to branch on which model it is talking to.
Instance Attribute Summary collapse
-
#finish_reason ⇒ Object
readonly
Returns the value of attribute finish_reason.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(message:, usage: {}, raw: nil, model: nil, finish_reason: nil) ⇒ Response
constructor
A new instance of Response.
-
#text ⇒ Object
The text content of the assistant turn (may be nil on a pure tool call).
- #tool_calls ⇒ Object
- #tool_calls? ⇒ Boolean
Constructor Details
#initialize(message:, usage: {}, raw: nil, model: nil, finish_reason: nil) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 16 17 |
# File 'lib/truffle/response.rb', line 11 def initialize(message:, usage: {}, raw: nil, model: nil, finish_reason: nil) @message = @usage = usage || {} @raw = raw @model = model @finish_reason = finish_reason end |
Instance Attribute Details
#finish_reason ⇒ Object (readonly)
Returns the value of attribute finish_reason.
9 10 11 |
# File 'lib/truffle/response.rb', line 9 def finish_reason @finish_reason end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/truffle/response.rb', line 9 def @message end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/truffle/response.rb', line 9 def model @model end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
9 10 11 |
# File 'lib/truffle/response.rb', line 9 def raw @raw end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
9 10 11 |
# File 'lib/truffle/response.rb', line 9 def usage @usage end |
Instance Method Details
#text ⇒ Object
The text content of the assistant turn (may be nil on a pure tool call).
20 21 22 |
# File 'lib/truffle/response.rb', line 20 def text .content end |
#tool_calls ⇒ Object
24 25 26 |
# File 'lib/truffle/response.rb', line 24 def tool_calls .tool_calls end |
#tool_calls? ⇒ Boolean
28 29 30 |
# File 'lib/truffle/response.rb', line 28 def tool_calls? .tool_calls? end |