RecastAI 3.0.0 → 3.1.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 +11 -3
- data/lib/recastai/apis/request/models/conversation.rb +38 -15
- data/lib/recastai/apis/request/models/response.rb +13 -11
- data/lib/recastai/utils.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815462dab5fa1be22867b8da2f81cbc2e5273edd
|
4
|
+
data.tar.gz: 990e593aa2e0ea07362f2af79b8453f7a3cd9641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74a8724a020b0477349acbae7e283f7c30408bd4b4594fd2b35ecbffc23e90cd8ea3a0cfc858f74b602bac1433fd18a2749719b387d45011e2bc9d0c86f66bc
|
7
|
+
data.tar.gz: e5c2cfef93104bfff29eec219ce03e334a1c992251299885ba1a96569754332230a8acb86ab928afc660e75d4d6746a2fbf1b7a563d73e67023d87e350ac7a2a
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
# Recast.AI - SDK Ruby
|
2
1
|
|
3
|
-
|
2
|
+
|
3
|
+
[logo]: https://cdn.recast.ai/brand/recast-ai-logo-inline.png "Recast.AI"
|
4
4
|
|
5
5
|
![alt text][logo]
|
6
6
|
|
7
|
+
# Recast.AI - SDK Ruby
|
8
|
+
|
7
9
|
Recast.AI official SDK in Ruby
|
8
10
|
|
9
11
|
## Synospis
|
@@ -27,7 +29,10 @@ Using the entire SDK:
|
|
27
29
|
```ruby
|
28
30
|
require 'recastai'
|
29
31
|
|
30
|
-
client = RecastAI.new('YOUR_TOKEN')
|
32
|
+
client = RecastAI::Client.new('YOUR_TOKEN')
|
33
|
+
|
34
|
+
client.request.analyse_text('Hi')
|
35
|
+
client.connect.broadcast_message('Hello')
|
31
36
|
```
|
32
37
|
|
33
38
|
Extracting one single API:
|
@@ -35,7 +40,10 @@ Extracting one single API:
|
|
35
40
|
require 'recastai'
|
36
41
|
|
37
42
|
request = RecastAI::Request.new('YOUR_TOKEN')
|
43
|
+
request.analyse_text('Hi')
|
44
|
+
|
38
45
|
connect = RecastAI::Connect.new('YOUR_TOKEN')
|
46
|
+
connect.broadcast_message('Hi')
|
39
47
|
```
|
40
48
|
|
41
49
|
## More
|
@@ -3,11 +3,12 @@
|
|
3
3
|
require_relative 'action'
|
4
4
|
require_relative 'entity'
|
5
5
|
require_relative 'intent'
|
6
|
+
require_relative '../utils'
|
6
7
|
|
7
8
|
module RecastAI
|
8
9
|
class Conversation
|
9
|
-
attr_reader :raw, :uuid, :source, :replies, :action, :next_actions, :memory, :entities, :intents,
|
10
|
-
:conversation_token, :language, :version, :timestamp, :status
|
10
|
+
attr_reader :raw, :uuid, :source, :replies, :action, :next_actions, :memory, :entities, :sentiment, :intents,
|
11
|
+
:conversation_token, :language, :processing_language, :version, :timestamp, :status
|
11
12
|
|
12
13
|
def initialize(response, token)
|
13
14
|
@token = token
|
@@ -17,19 +18,21 @@ module RecastAI
|
|
17
18
|
response = JSON.parse(response)
|
18
19
|
response = response['results']
|
19
20
|
|
20
|
-
@uuid
|
21
|
-
@source
|
22
|
-
@replies
|
23
|
-
@action
|
24
|
-
@next_actions
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
21
|
+
@uuid = response['uuid']
|
22
|
+
@source = response['source']
|
23
|
+
@replies = response['replies']
|
24
|
+
@action = response['action'] ? Action.new(response['action']) : nil
|
25
|
+
@next_actions = response['next_actions'].map{ |i| Action.new(i) }
|
26
|
+
@sentiment = response['sentiment']
|
27
|
+
@memory = response['memory'].reject { |_, e| e.nil? }.map{ |n, e| Entity.new(n, e) }
|
28
|
+
@entities = response['entities'].flat_map{ |_, e| e.map{ |ee| Entity.new(n, ee) } }
|
29
|
+
@intents = response['intents'].map{ |i| Intent.new(i) }
|
30
|
+
@conversation_token = response['conversation_token']
|
31
|
+
@language = response['language']
|
32
|
+
@processing_language = response['processing_language']
|
33
|
+
@version = response['version']
|
34
|
+
@timestamp = response['timestamp']
|
35
|
+
@status = response['status']
|
33
36
|
end
|
34
37
|
|
35
38
|
def reply
|
@@ -58,6 +61,26 @@ module RecastAI
|
|
58
61
|
@intents.any? ? @intents.first : nil
|
59
62
|
end
|
60
63
|
|
64
|
+
def vpositive?
|
65
|
+
@sentiment == Utils::SENTIMENT_VPOSITIVE
|
66
|
+
end
|
67
|
+
|
68
|
+
def positive?
|
69
|
+
@sentiment == Utils::SENTIMENT_POSITIVE
|
70
|
+
end
|
71
|
+
|
72
|
+
def neutral?
|
73
|
+
@sentiment == Utils::SENTIMENT_NEUTRAL
|
74
|
+
end
|
75
|
+
|
76
|
+
def negative?
|
77
|
+
@sentiment == Utils::SENTIMENT_NEGATIVE
|
78
|
+
end
|
79
|
+
|
80
|
+
def vnegative?
|
81
|
+
@sentiment == Utils::SENTIMENT_VNEGATIVE
|
82
|
+
end
|
83
|
+
|
61
84
|
def set_memory(memory)
|
62
85
|
body = { conversation_token: @conversation_token, memory: memory }
|
63
86
|
response = HTTParty.put(
|
@@ -15,6 +15,7 @@ module RecastAI
|
|
15
15
|
attr_reader :sentiment
|
16
16
|
attr_reader :entities
|
17
17
|
attr_reader :language
|
18
|
+
attr_reader :processing_language
|
18
19
|
attr_reader :version
|
19
20
|
attr_reader :timestamp
|
20
21
|
attr_reader :status
|
@@ -25,17 +26,18 @@ module RecastAI
|
|
25
26
|
response = JSON.parse(response)
|
26
27
|
response = response['results']
|
27
28
|
|
28
|
-
@uuid
|
29
|
-
@source
|
30
|
-
@intents
|
31
|
-
@act
|
32
|
-
@type
|
33
|
-
@sentiment
|
34
|
-
@entities
|
35
|
-
@language
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
29
|
+
@uuid = response['uuid']
|
30
|
+
@source = response['source']
|
31
|
+
@intents = response['intents'].map{ |i| Intent.new(i) }
|
32
|
+
@act = response['act']
|
33
|
+
@type = response['type']
|
34
|
+
@sentiment = response['sentiment']
|
35
|
+
@entities = response['entities'].flat_map{ |n, e| e.map{ |ee| Entity.new(n, ee) } }
|
36
|
+
@language = response['language']
|
37
|
+
@processing_language = response['processing_language']
|
38
|
+
@version = response['version']
|
39
|
+
@timestamp = response['timestamp']
|
40
|
+
@status = response['status']
|
39
41
|
end
|
40
42
|
|
41
43
|
def intent
|
data/lib/recastai/utils.rb
CHANGED
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.
|
4
|
+
version: 3.1.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-
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|