Class: SmartAgent::Result

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ 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
20
21
22
23
# 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
      unless tool_calls.empty?
        return tool_calls
      else
        return false
      end            
    else
      return false
    end
  end
end

#contentObject



25
26
27
28
29
30
31
# File 'lib/smart_agent/result.rb', line 25

def content
  if @response.class == Hash
    @response.dig("choices", 0, "message", "content")
  else
    @response
  end
end

#responseObject



33
34
35
# File 'lib/smart_agent/result.rb', line 33

def response
  @response
end