nlpcloud 1.0.31 → 1.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nlpcloud.rb +24 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb4e5c8f1aa77a198f1d1fadda322c9e8a9dc66c529b101a33c01e90ebc5699c
4
- data.tar.gz: 910f32909dc6765d5bbb50f060562feb9d8e0f1f32f52220e2eeb769852ba683
3
+ metadata.gz: 4c28175e7facf332c54a9f656cd1f71764d6da8f126921f41e2f12501d9eb699
4
+ data.tar.gz: 81c618dbc777f5441712060e75212f024bb21f87d2f097c5fa24cc071e8a4677
5
5
  SHA512:
6
- metadata.gz: ec46f16688f748780c891ca3b1f3410b388e8bd111a84162d6f22452b596bf222aeb8b066ca3063dc990759a7069c04102c692694db9d92f14c662e882fad79f
7
- data.tar.gz: 28bb026f06a86c9513baea2179673d01a5a66877eded008de227257a9faf4d9cee2ecac42b5ef66e00fad7a60bac8fb51d54634d8e2966fd518b6dbd23fe0ede
6
+ metadata.gz: ff21d7011299947208a87ec374f88891376ef616df59eff21ab0dd85959425aa2f13cf328f20d72bd3324b40c89e12225cb6fa04a0737cda0fa5d8f71d59b977
7
+ data.tar.gz: dea43da82e56a084e8e87ea6e9d808e5fac01c694a9a57a5c5588c2962d0e1418026b621d0de0b6fae85de8a02314ccf80245adfd4cc9cd20d96a45896f2bdec
data/lib/nlpcloud.rb CHANGED
@@ -9,26 +9,33 @@ module NLPCloud
9
9
 
10
10
  # Client requests the API.
11
11
  class Client
12
- def initialize(model, token, gpu: false, lang: '')
12
+ def initialize(model, token, gpu: false, lang: '', asynchronous: false)
13
13
  @headers = {
14
14
  'Authorization' => "Token #{token}",
15
15
  'Content-Type' => 'application/json',
16
16
  'User-Agent' => 'nlpcloud-ruby-client'
17
17
  }
18
18
 
19
- if lang == 'en'
20
- lang = ''
19
+ @root_url = "#{BASE_URL}/#{API_VERSION}/"
20
+
21
+ if lang == "en"
22
+ lang = ""
23
+ end
24
+
25
+ if gpu
26
+ @root_url += "gpu/"
21
27
  end
22
28
 
23
- @root_url = if gpu && (lang != '')
24
- "#{BASE_URL}/#{API_VERSION}/gpu/#{lang}/#{model}"
25
- elsif gpu && (lang == '')
26
- "#{BASE_URL}/#{API_VERSION}/gpu/#{model}"
27
- elsif !gpu && (lang != '')
28
- "#{BASE_URL}/#{API_VERSION}/#{lang}/#{model}"
29
- else
30
- "#{BASE_URL}/#{API_VERSION}/#{model}"
31
- end
29
+ if lang
30
+ @root_url += lang + "/"
31
+ end
32
+
33
+ if asynchronous
34
+ @root_url += "async/"
35
+ end
36
+
37
+ @root_url += model
38
+
32
39
  end
33
40
 
34
41
  def ad_generation(keywords)
@@ -55,6 +62,11 @@ module NLPCloud
55
62
  JSON.parse(response.body)
56
63
  end
57
64
 
65
+ def async_result(url)
66
+ response = RestClient.get(url, @headers)
67
+ JSON.parse(response.body)
68
+ end
69
+
58
70
  def chatbot(text, context: nil, history: nil)
59
71
  payload = {
60
72
  'text' => text,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nlpcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.31
4
+ version: 1.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Salinas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-25 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client