nlpcloud 1.0.10 → 1.0.14

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 +30 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a4b97770d4b1a6f6daf5c3365f5dbe266e82113ab54b4219cf414458aa7907
4
- data.tar.gz: ec629fbc99105b49cb4f90b90b42b2ad812d509c808d28b77859b61dc7c2b4e1
3
+ metadata.gz: 5a625122c70741c70a1d3bf335696ade3bfc453f069f85c57737ee457509ba18
4
+ data.tar.gz: 496cc60651689612fd01f6d73d22242ec559eb139241debd7fe6367cb725cfda
5
5
  SHA512:
6
- metadata.gz: a618257dc0d197126b16698d51957209989b533bbcaf731c6ac4a7987c25ad83b712688d14ea5b3bccdf61c5c8a7675bd0786f30ca5ddb8dca6a6a69f1307f7c
7
- data.tar.gz: db964aa4c66127a60c64e19b21c8377969f83eec024b1dab3dd3d85ed47d31ece8458ee7cebca7c664b3bb993eae69d028bdfe04c3f5fa2afc965f92c827e49a
6
+ metadata.gz: 76b87c80b41bd0ce5c6640c82565f93dcdcf7dc0689784c82020f88bafc95503ef97531e1491e03cd63f73d45a731feff04e2c6d776d05c3fc2c90f009a10632
7
+ data.tar.gz: '04281a7294ffebc7bb448d190cb617aaba7755d7d6b461e4d353eb4120083127c96db5c42dee219df36a76710a4f4ca61b5836c41a75b1ed2670e13277ce49e8'
data/lib/nlpcloud.rb CHANGED
@@ -12,7 +12,8 @@ module NLPCloud
12
12
  def initialize(model, token, gpu: false)
13
13
  @headers = {
14
14
  'Authorization' => "Token #{token}",
15
- "User-Agent": 'nlploud-ruby-client'
15
+ 'Content-Type' => 'application/json',
16
+ 'User-Agent' => 'nlpcloud-ruby-client'
16
17
  }
17
18
 
18
19
  @root_url = if gpu
@@ -30,7 +31,7 @@ module NLPCloud
30
31
  JSON.parse(response.body)
31
32
  end
32
33
 
33
- def classification(text, labels, multi_class)
34
+ def classification(text, labels, multi_class: nil)
34
35
  payload = {
35
36
  'text' => text,
36
37
  'labels' => labels,
@@ -40,6 +41,33 @@ module NLPCloud
40
41
  JSON.parse(response.body)
41
42
  end
42
43
 
44
+ def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
45
+ end_sequence: nil, remove_input: nil, do_sample: nil, num_beams: nil, early_stopping: nil,
46
+ no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
47
+ temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil)
48
+ payload = {
49
+ 'text' => text,
50
+ 'min_length' => min_length,
51
+ 'max_length' => max_length,
52
+ 'length_no_input' => length_no_input,
53
+ 'end_sequence' => end_sequence,
54
+ 'remove_input' => remove_input,
55
+ 'do_sample' => do_sample,
56
+ 'num_beams' => num_beams,
57
+ 'early_stopping' => early_stopping,
58
+ 'no_repeat_ngram_size' => no_repeat_ngram_size,
59
+ 'num_return_sequences' => num_return_sequences,
60
+ 'top_k' => top_k,
61
+ 'top_p' => top_p,
62
+ 'temperature' => temperature,
63
+ 'repetition_penalty' => repetition_penalty,
64
+ 'length_penalty' => length_penalty,
65
+ 'bad_words' => bad_words
66
+ }
67
+ response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
68
+ JSON.parse(response.body)
69
+ end
70
+
43
71
  def sentiment(text)
44
72
  payload = {
45
73
  '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.10
4
+ version: 1.0.14
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-07-25 00:00:00.000000000 Z
11
+ date: 2022-01-10 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,