Class: FuzzyAi::Account

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/fuzzy.ai.rb

Overview

Fuzzy.ai Account object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Account

Returns a new instance of Account.



13
14
15
16
17
18
19
20
# File 'lib/fuzzy.ai.rb', line 13

def initialize(key)
  @key = key
  @headers = {
    'Content-Type' => 'application/json',
    'Authorization' => 'Bearer ' + key,
    'User-Agent' => "fuzzy.ai-ruby/#{VERSION}"
  }
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/fuzzy.ai.rb', line 11

def key
  @key
end

Instance Method Details

#evaluate(agent_id, inputs) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/fuzzy.ai.rb', line 22

def evaluate(agent_id, inputs)
  body = inputs.to_json
  headers = @headers.merge('Content-Length' => body.length.to_s)
  options = { headers: headers, body: body }

  response = self.class.post("/agent/#{agent_id}", options)
  id = response.headers['X-Evaluation-ID']
  [response, id]
end

#feedback(evaluation_id, performance) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/fuzzy.ai.rb', line 32

def feedback(evaluation_id, performance)
  body = performance.to_json
  headers = @headers.merge('Content-Length' => body.length.to_s)
  options = { headers: headers, body: body }

  self.class.post("/evaluation/#{evaluation_id}/feedback", options)
end