Class: PromptObjects::LLM::Response
- Inherits:
-
Object
- Object
- PromptObjects::LLM::Response
- Defined in:
- lib/prompt_objects/llm/response.rb
Overview
Normalized response from an LLM API call. Wraps provider-specific responses into a common interface.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#tool_calls ⇒ Object
readonly
Returns the value of attribute tool_calls.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(content:, tool_calls: [], raw: nil, usage: nil) ⇒ Response
constructor
A new instance of Response.
-
#tool_calls? ⇒ Boolean
Check if the response includes tool calls.
Constructor Details
#initialize(content:, tool_calls: [], raw: nil, usage: nil) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 |
# File 'lib/prompt_objects/llm/response.rb', line 10 def initialize(content:, tool_calls: [], raw: nil, usage: nil) @content = content @tool_calls = tool_calls @raw = raw @usage = usage # { input_tokens:, output_tokens:, model:, provider: } end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/prompt_objects/llm/response.rb', line 8 def content @content end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/prompt_objects/llm/response.rb', line 8 def raw @raw end |
#tool_calls ⇒ Object (readonly)
Returns the value of attribute tool_calls.
8 9 10 |
# File 'lib/prompt_objects/llm/response.rb', line 8 def tool_calls @tool_calls end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
8 9 10 |
# File 'lib/prompt_objects/llm/response.rb', line 8 def usage @usage end |
Instance Method Details
#tool_calls? ⇒ Boolean
Check if the response includes tool calls.
19 20 21 |
# File 'lib/prompt_objects/llm/response.rb', line 19 def tool_calls? !@tool_calls.empty? end |