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 +4 -4
- data/README.md +1 -1
- data/lib/recastai/apis/build/build.rb +14 -5
- data/lib/recastai/apis/build/dialog_response.rb +3 -2
- data/lib/recastai/apis/request/analyse.rb +0 -18
- data/lib/recastai/utils.rb +2 -2
- data/recastai.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d552d240bb34da2f63d3d57724c9d08ebe188792
|
4
|
+
data.tar.gz: 949f16a3e43c5fb357397f98b058b3ac9256bda0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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) [
|
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
|
-
|
26
|
-
|
25
|
+
log_level = options[:log_level] || "info"
|
26
|
+
proxy = options[:proxy] || {}
|
27
27
|
|
28
|
-
|
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
|
data/lib/recastai/utils.rb
CHANGED
data/recastai.gemspec
CHANGED
@@ -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.
|
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:
|
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:
|
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.
|
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.
|
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
|