Class: RubyCanUseLLM::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycanusellm/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, model:, input_tokens:, output_tokens:, raw:, tool_calls: nil) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
14
# File 'lib/rubycanusellm/response.rb', line 7

def initialize(content:, model:, input_tokens:, output_tokens:, raw:, tool_calls: nil)
  @content = content
  @model = model
  @input_tokens = input_tokens
  @output_tokens = output_tokens
  @tool_calls = tool_calls
  @raw = raw
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def content
  @content
end

#input_tokensObject (readonly)

Returns the value of attribute input_tokens.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def input_tokens
  @input_tokens
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def model
  @model
end

#output_tokensObject (readonly)

Returns the value of attribute output_tokens.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def output_tokens
  @output_tokens
end

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def raw
  @raw
end

#tool_callsObject (readonly)

Returns the value of attribute tool_calls.



5
6
7
# File 'lib/rubycanusellm/response.rb', line 5

def tool_calls
  @tool_calls
end

Instance Method Details

#tool_call?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rubycanusellm/response.rb', line 16

def tool_call?
  !tool_calls.nil? && !tool_calls.empty?
end

#total_tokensObject



20
21
22
# File 'lib/rubycanusellm/response.rb', line 20

def total_tokens
  input_tokens + output_tokens
end