nlpcloud 1.0.12 → 1.0.16

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nlpcloud.rb +18 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d15c8d10001f6858a03294421913df01689dc776786f22292ec4f02f0d73a83
4
- data.tar.gz: 3b1bfc5e7dd10844cb6f714e4d6749579c81528fd5599cf76b52129677f2d510
3
+ metadata.gz: 8890ee672b4124102ff817b4b0eaeb729a0de1a3e3c667aea55e70c2f01615eb
4
+ data.tar.gz: ce274efee4aa6e6284c7d2f9e1bf2f0b866e197460b23b7c80bed66cf9d10896
5
5
  SHA512:
6
- metadata.gz: 701204c9a11f8000d618ffd9bab25f922e2607d48790931669843371927601336aa0d06ed9a8e4f911d7bc00a0c4f2e829b23d57c230530d941157f5c61367cb
7
- data.tar.gz: cc2d2bab211b74a071aab5f9262360b81517d0f82bad2b8081981ffeb6f35ac3e3f1fb2e3546d57c9b7fa2623bf4b137069bd4cb27a9fa6ef2592a3ada1da294
6
+ metadata.gz: 45a4ac5bfde7f70bfbb492d5d6a69d65e4aebb4de8d0764c2ff8a4949a996b7a214f9cdb4f46be6681bad15f81b284b93398b89482ba6cdfc28de4e79c941cb4
7
+ data.tar.gz: '07285e336c7c1472c379d68a0a7c9c13effd46512f0a033e0ee0f23fb8b77063a995d3deae73a59f1b8ed5c5c11377d99042baba52d8633897b63414fb28b62e'
data/lib/nlpcloud.rb CHANGED
@@ -9,14 +9,19 @@ module NLPCloud
9
9
 
10
10
  # Client requests the API.
11
11
  class Client
12
- def initialize(model, token, gpu: false)
12
+ def initialize(model, token, gpu: false, lang: '')
13
13
  @headers = {
14
14
  'Authorization' => "Token #{token}",
15
+ 'Content-Type' => 'application/json',
15
16
  'User-Agent' => 'nlpcloud-ruby-client'
16
17
  }
17
18
 
18
- @root_url = if gpu
19
+ @root_url = if gpu && (lang != '')
20
+ "#{BASE_URL}/#{API_VERSION}/gpu/#{lang}/#{model}"
21
+ elsif gpu && (lang == '')
19
22
  "#{BASE_URL}/#{API_VERSION}/gpu/#{model}"
23
+ elsif !gpu && (lang != '')
24
+ "#{BASE_URL}/#{API_VERSION}/#{lang}/#{model}"
20
25
  else
21
26
  "#{BASE_URL}/#{API_VERSION}/#{model}"
22
27
  end
@@ -41,8 +46,9 @@ module NLPCloud
41
46
  end
42
47
 
43
48
  def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
44
- end_sequence: nil, remove_input: nil, top_k: nil, top_p: nil,
45
- temperature: nil, repetition_penalty: nil, length_penalty: nil)
49
+ end_sequence: nil, remove_input: nil, do_sample: nil, num_beams: nil, early_stopping: nil,
50
+ no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
51
+ temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil, remove_end_sequence: nil)
46
52
  payload = {
47
53
  'text' => text,
48
54
  'min_length' => min_length,
@@ -50,11 +56,18 @@ module NLPCloud
50
56
  'length_no_input' => length_no_input,
51
57
  'end_sequence' => end_sequence,
52
58
  'remove_input' => remove_input,
59
+ 'do_sample' => do_sample,
60
+ 'num_beams' => num_beams,
61
+ 'early_stopping' => early_stopping,
62
+ 'no_repeat_ngram_size' => no_repeat_ngram_size,
63
+ 'num_return_sequences' => num_return_sequences,
53
64
  'top_k' => top_k,
54
65
  'top_p' => top_p,
55
66
  'temperature' => temperature,
56
67
  'repetition_penalty' => repetition_penalty,
57
- 'length_penalty' => length_penalty
68
+ 'length_penalty' => length_penalty,
69
+ 'bad_words' => bad_words,
70
+ 'remove_end_sequence' => remove_end_sequence
58
71
  }
59
72
  response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
60
73
  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.12
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Salinas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-24 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'NLP Cloud serves high performance pre-trained or custom models for NER,
14
14
  sentiment-analysis, classification, summarization, text generation, question answering,