nlpcloud 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nlpcloud.rb +27 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea136747ee1261849ff8b2d88e600eb77d2abc7b26403dd8bfcd00ae090ef023
|
4
|
+
data.tar.gz: f703208b4178296fdb158272e63fbbcd213a0c199c69feb2caf657dbf7c756fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2190fcca487d4987040b4be0a97bd28e713c018b04d603e91dd11973d4cee29c04e6e93e08c22868277e99fedad3a66815cf2953f8a5f83609e69babb8bbd7f0
|
7
|
+
data.tar.gz: b491d82840b0bd4a7b958f4317912fd610ce80331a25bf6488d1330782d52bb4c6d8893e5ce5886affe09aefacb65b976edbb5c62d1d599375fc0dc3998ca121
|
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
|
-
|
20
|
-
|
19
|
+
@root_url = "#{BASE_URL}/#{API_VERSION}/"
|
20
|
+
|
21
|
+
if lang == "en"
|
22
|
+
lang = ""
|
23
|
+
end
|
24
|
+
|
25
|
+
if gpu
|
26
|
+
@root_url += "gpu/"
|
27
|
+
end
|
28
|
+
|
29
|
+
if lang
|
30
|
+
@root_url += lang + "/"
|
31
|
+
end
|
32
|
+
|
33
|
+
if asynchronous
|
34
|
+
@root_url += "async/"
|
21
35
|
end
|
22
36
|
|
23
|
-
@root_url
|
24
|
-
|
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
|
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(@root_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,
|
@@ -230,9 +242,10 @@ module NLPCloud
|
|
230
242
|
JSON.parse(response.body)
|
231
243
|
end
|
232
244
|
|
233
|
-
def summarization(text)
|
245
|
+
def summarization(text, size: nil)
|
234
246
|
payload = {
|
235
|
-
'text' => text
|
247
|
+
'text' => text,
|
248
|
+
'size' => size
|
236
249
|
}
|
237
250
|
response = RestClient.post("#{@root_url}/summarization", payload.to_json, @headers)
|
238
251
|
JSON.parse(response.body)
|
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.
|
4
|
+
version: 1.0.32
|
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-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|