Class: SmartAgent::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_agent/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Result

Returns a new instance of Result.



3
4
5
6
# File 'lib/smart_agent/result.rb', line 3

def initialize(response)
  SmartAgent.logger.info("response is:" + response.to_s)
  @response = response
end

Instance Method Details

#call_toolsObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/smart_agent/result.rb', line 8

def call_tools
  if @response.class == String
    return false
  else
    tool_calls = @response.dig("choices", 0, "message", "tool_calls")
    if tool_calls.empty?
      return false
    else
      return tool_calls
    end
  end
end

#contentObject



21
22
23
# File 'lib/smart_agent/result.rb', line 21

def content
  @response.dig("choices", 0, "message", "content")
end

#responseObject



25
26
27
# File 'lib/smart_agent/result.rb', line 25

def response
  @response
end