RecastAI 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3775640528153be33dbad2afa118676fae716a4d
4
- data.tar.gz: 51715b59420d86284953a04a7683b4774a3c48a5
3
+ metadata.gz: d552d240bb34da2f63d3d57724c9d08ebe188792
4
+ data.tar.gz: 949f16a3e43c5fb357397f98b058b3ac9256bda0
5
5
  SHA512:
6
- metadata.gz: 1f237a24246e81ffe3411a06de47c1564223d2db861533c7352715fe5ed2c1bb46b84d2e920410faecdd46da5f0a5f18a05b36e2ba42b28b66369b36bdfde489
7
- data.tar.gz: 4658edfbc0fb383f441fb9f2b4b7e0daace19f3c147b47efe0bbbf1aae909ffb8ee56075b00ca04e417811c0b53333d83ff36295d8e6170f3a25e4330eb63a19
6
+ metadata.gz: fb549d075ee9027d8f29c66abab0641c44b34e7e287da43acdc22b5e0331d1725e7c437bdfa2a9fe23e37695200c706eda8ff05fe939d2fac929a69dce206c56
7
+ data.tar.gz: 1d35b3c1468a5a85c42dd4314d2032f6e8c9d82a7eb54f64330eac1a6a7bef8dbfdd4293b02f6789efcb66e7035f17f0ccda5785a468a2b285f2da436eec3878
data/README.md CHANGED
@@ -60,7 +60,7 @@ You can follow us on Twitter at [@recastai](https://twitter.com/recastai) for up
60
60
 
61
61
  ## License
62
62
 
63
- Copyright (c) [2017] [Recast.AI](https://recast.ai)
63
+ Copyright (c) [2018] [Recast.AI](https://recast.ai)
64
64
 
65
65
  Permission is hereby granted, free of charge, to any person obtaining a copy
66
66
  of this software and associated documentation files (the "Software"), to deal
@@ -19,17 +19,26 @@ module RecastAI
19
19
  { 'Authorization' => "Token #{@token}", 'Content-Type' => 'application/json' }
20
20
  end
21
21
 
22
- def dialog(msg, conversation_id, language = nil)
22
+ def dialog(msg, conversation_id, language = nil, options = {})
23
23
  raise RecastAI::RecastError.new('Token is missing') unless @token
24
24
 
25
- language = @language if language.nil?
26
- body = { message: msg, conversation_id: conversation_id, language: language }
25
+ log_level = options[:log_level] || "info"
26
+ proxy = options[:proxy] || {}
27
27
 
28
- response = HTTParty.post("#{RecastAI::Utils::BUILD_ENDPOINT}/dialog", body: body.to_json, headers: self.headers)
28
+ language = @language if language.nil?
29
+ body = { message: msg, conversation_id: conversation_id, language: language, log_level: log_level}
30
+ body[:memory] = options[:memory] unless options[:memory].nil?
31
+
32
+ options = { body: body.to_json, headers: self.headers }
33
+ if proxy != {}
34
+ options[:http_proxyaddr] = proxy[:host]
35
+ options[:http_proxyport] = proxy[:port]
36
+ end
37
+ response = HTTParty.post("#{RecastAI::Utils::BUILD_ENDPOINT}/dialog", options)
29
38
  raise RecastAI::RecastError.new(JSON.parse(response.body)['message']) if response.code != 200
30
39
 
31
40
  res = JSON.parse(response.body)['results']
32
- RecastAI::DialogResponse.new(res['messages'], res['conversation'], res['nlp'])
41
+ RecastAI::DialogResponse.new(res['messages'], res['conversation'], res['nlp'], res['logs'])
33
42
  end
34
43
 
35
44
  def update_conversation(user, bot, conversation_id, opts)
@@ -3,14 +3,15 @@ require_relative 'dialog_conversation'
3
3
  require_relative '../request/models/response'
4
4
  module RecastAI
5
5
  class DialogResponse
6
- attr_reader :messages, :conversation, :nlp
6
+ attr_reader :messages, :conversation, :nlp, :logs
7
7
 
8
- def initialize(messages, conversation, nlp)
8
+ def initialize(messages, conversation, nlp, logs)
9
9
  raise RecastAI::RecastError("Invalid messages format: #{messages}") unless messages.is_a?(Array)
10
10
 
11
11
  @messages = messages.map{ |m| RecastAI::DialogMessage.new(m) }
12
12
  @conversation = DialogConversation.new(conversation)
13
13
  @nlp = Response.new('results' => nlp)
14
+ @logs = logs
14
15
  end
15
16
  end
16
17
  end
@@ -23,23 +23,5 @@ module RecastAI
23
23
 
24
24
  Response.new(JSON.parse(response.body))
25
25
  end
26
-
27
- def analyse_file(file, token: nil, language: nil)
28
- token ||= @token
29
- raise RecastError.new('Token is missing') if token.nil?
30
-
31
- language ||= @language
32
-
33
- body = { voice: File.new(file) }
34
- body[:language] = language unless language.nil?
35
- response = HTTMultiParty.post(
36
- Utils::REQUEST_ENDPOINT,
37
- body: body,
38
- headers: { 'Authorization' => "Token #{token}" }
39
- )
40
- raise RecastError.new(JSON.parse(response.body)['message']) if response.code != 200
41
-
42
- Response.new(JSON.parse(response.body))
43
- end
44
26
  end
45
27
  end
@@ -3,8 +3,8 @@
3
3
  module RecastAI
4
4
  class Utils
5
5
  # Versioning
6
- MAJOR = '3'.freeze
7
- MINOR = '2'.freeze
6
+ MAJOR = '4'.freeze
7
+ MINOR = '0'.freeze
8
8
  PATCH = '0'.freeze
9
9
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}".freeze
10
10
 
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec', '~> 3.4'
28
28
  spec.add_development_dependency 'webmock', '~> 1.24'
29
29
  spec.add_development_dependency 'awesome_print', '~> 1.6'
30
- spec.add_development_dependency 'simplecov', '~> 0.11'
30
+ spec.add_development_dependency 'simplecov', '~> 0.15'
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RecastAI
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Renvoisé
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-21 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.11'
89
+ version: '0.15'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.11'
96
+ version: '0.15'
97
97
  description: Recast.AI official SDK for Ruby. Allows you to make requests to your
98
98
  bots.
99
99
  email: paul.renvoise@recast.ai
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.5.2
157
+ rubygems_version: 2.5.2.3
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Recast.AI official SDK for Ruby