Class: PromptObjects::LLM::Response

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/prompt_objects/llm/response.rb', line 8

def content
  @content
end

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/prompt_objects/llm/response.rb', line 8

def raw
  @raw
end

#tool_callsObject (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

#usageObject (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.

Returns:

  • (Boolean)


19
20
21
# File 'lib/prompt_objects/llm/response.rb', line 19

def tool_calls?
  !@tool_calls.empty?
end