Comparing version 1.0.48 to 1.0.49
export = Client; | ||
declare class Client { | ||
constructor(model: string, token: string, gpu?: boolean, lang?: string, asynchronous?: boolean); | ||
constructor(params: { | ||
model: string; | ||
token: string; | ||
gpu?: boolean; | ||
lang?: string; | ||
async?: boolean; | ||
}); | ||
headers: { | ||
@@ -10,3 +16,5 @@ Authorization: string; | ||
adGeneration(keywords: string[]): Promise<{ | ||
adGeneration(params: { | ||
keywords: string[] | ||
}): Promise<{ | ||
status: number; | ||
@@ -18,3 +26,8 @@ statusText: string; | ||
}>; | ||
asr(url?: string, encodedFile?: string, inputLanguage?: string): Promise<{ | ||
asr(params: { | ||
url?: string, | ||
encodedFile?: string, | ||
inputLanguage?: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -35,3 +48,6 @@ statusText: string; | ||
}>; | ||
asyncResult(url: string): Promise<{ | ||
asyncResult(params: { | ||
url: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -48,3 +64,8 @@ statusText: string; | ||
}>; | ||
chatbot(input: string, context: string, history: { input: string, response: string }[]): Promise<{ | ||
chatbot(params: { | ||
input: string, | ||
context?: string, | ||
history?: { input: string, response: string }[] | ||
}): Promise<{ | ||
status: number; | ||
@@ -57,3 +78,8 @@ statusText: string; | ||
}>; | ||
classification(text: string, labels: string[], multiClass?: boolean): Promise<{ | ||
classification(params: { | ||
text: string, | ||
labels?: string[], | ||
multiClass?: boolean | ||
}): Promise<{ | ||
status: number; | ||
@@ -66,3 +92,6 @@ statusText: string; | ||
}>; | ||
codeGeneration(instruction: string): Promise<{ | ||
codeGeneration(params: { | ||
instruction: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -74,3 +103,6 @@ statusText: string; | ||
}>; | ||
dependencies(text: string): Promise<{ | ||
dependencies(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -82,3 +114,6 @@ statusText: string; | ||
}>; | ||
embeddings(text: string[]): Promise<{ | ||
embeddings(params: { | ||
sentences: string[] | ||
}): Promise<{ | ||
status: number; | ||
@@ -90,3 +125,7 @@ statusText: string; | ||
}>; | ||
entities(text: string, searchedEntity?: string): Promise<{ | ||
entities(params: { | ||
text: string, | ||
searchedEntity?: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -98,3 +137,4 @@ statusText: string; | ||
}>; | ||
generation(text: string, | ||
generation(params: {text: string, | ||
maxLength?: number, | ||
@@ -110,3 +150,4 @@ lengthNoInput?: boolean, | ||
repetitionPenalty?: number, | ||
removeEndSequence?: boolean): Promise<{ | ||
removeEndSequence?: boolean | ||
}): Promise<{ | ||
status: number; | ||
@@ -120,3 +161,6 @@ statusText: string; | ||
}>; | ||
gsCorrection(text: string): Promise<{ | ||
gsCorrection(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -134,3 +178,6 @@ statusText: string; | ||
}>; | ||
imageGeneration(text: string): Promise<{ | ||
imageGeneration(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -142,3 +189,6 @@ statusText: string; | ||
}>; | ||
intentClassification(text: string): Promise<{ | ||
intentClassification(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -150,3 +200,6 @@ statusText: string; | ||
}>; | ||
kwKpExtraction(text: string): Promise<{ | ||
kwKpExtraction(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -158,3 +211,6 @@ statusText: string; | ||
}>; | ||
langdetection(text: string): Promise<{ | ||
langdetection(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -166,2 +222,3 @@ statusText: string; | ||
}>; | ||
libVersions(): Promise<{ | ||
@@ -172,3 +229,6 @@ status: number; | ||
}>; | ||
paraphrasing(text: string): Promise<{ | ||
paraphrasing(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -186,3 +246,7 @@ statusText: string; | ||
}>; | ||
question(context: string, question: string): Promise<{ | ||
question(params: { | ||
context?: string, | ||
question: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -197,3 +261,7 @@ statusText: string; | ||
}>; | ||
semanticSearch(text: string, numResults: number): Promise<{ | ||
semanticSearch(params: { | ||
text: string, | ||
numResults?: number | ||
}): Promise<{ | ||
status: number; | ||
@@ -205,3 +273,6 @@ statusText: string; | ||
}>; | ||
semanticSimilarity(sentences: string[]): Promise<{ | ||
semanticSimilarity(params: { | ||
sentences: string[] | ||
}): Promise<{ | ||
status: number; | ||
@@ -213,3 +284,6 @@ statusText: string; | ||
}>; | ||
sentenceDependencies(text: string): Promise<{ | ||
sentenceDependencies(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -221,3 +295,6 @@ statusText: string; | ||
}>; | ||
sentiment(text: string): Promise<{ | ||
sentiment(params: { | ||
text: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -229,3 +306,6 @@ statusText: string; | ||
}>; | ||
speechSynthesis(text: string, voice?: string): Promise<{ | ||
speechSynthesis(params: { | ||
text: string, | ||
voice?: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -237,3 +317,7 @@ statusText: string; | ||
}>; | ||
summarization(text: string, size?: string): Promise<{ | ||
summarization(params: { | ||
text: string, | ||
size?: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -251,3 +335,8 @@ statusText: string; | ||
}>; | ||
translation(text: string, source: string, target: string): Promise<{ | ||
translation(params: { | ||
text: string, | ||
source?: string, | ||
target: string | ||
}): Promise<{ | ||
status: number; | ||
@@ -254,0 +343,0 @@ statusText: string; |
135
index.js
@@ -7,3 +7,9 @@ const axios = require('axios') | ||
class Client { | ||
constructor(model, token, gpu = false, lang = '', asynchronous = false) { | ||
constructor(params) { | ||
var model = params.model | ||
var token = params.token | ||
var gpu = params.gpu ?? false | ||
var lang = params.lang ?? '' | ||
var async = params.async ?? false | ||
this.headers = { | ||
@@ -27,3 +33,3 @@ 'Authorization': 'Token ' + token, | ||
if (asynchronous) { | ||
if (async) { | ||
this.rootURL += "async/" | ||
@@ -40,3 +46,5 @@ } | ||
adGeneration(keywords) { | ||
adGeneration(params) { | ||
var keywords = params.keywords | ||
const payload = { | ||
@@ -49,3 +57,7 @@ 'keywords': keywords | ||
asr(url = null, encodedFile = null, inputLanguage = null) { | ||
asr(params) { | ||
var url = params.url ?? null | ||
var encodedFile = params.encodedFile ?? null | ||
var inputLanguage = params.inputLanguage ?? null | ||
const payload = { | ||
@@ -60,7 +72,13 @@ 'url': url, | ||
asyncResult(url) { | ||
asyncResult(params) { | ||
var url = params.url | ||
return axios.get(url, { headers: this.headers }) | ||
} | ||
chatbot(input, context = null, history = null) { | ||
chatbot(params) { | ||
var input = params.input | ||
var context = params.context ?? null | ||
var history = params.history ?? null | ||
const payload = { | ||
@@ -75,3 +93,7 @@ 'input': input, | ||
classification(text, labels = null, multiClass = null) { | ||
classification(params) { | ||
var text = params.text | ||
var labels = params.labels ?? null | ||
var multiClass = params.multiClass ?? null | ||
const payload = { | ||
@@ -86,3 +108,5 @@ 'text': text, | ||
codeGeneration(instruction) { | ||
codeGeneration(params) { | ||
var instruction = params.instruction | ||
const payload = { | ||
@@ -95,3 +119,5 @@ 'instruction': instruction | ||
dependencies(text) { | ||
dependencies(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -104,3 +130,5 @@ 'text': text | ||
embeddings(sentences) { | ||
embeddings(params) { | ||
var sentences = params.sentences | ||
const payload = { | ||
@@ -113,3 +141,6 @@ 'sentences': sentences | ||
entities(text, searchedEntity = null) { | ||
entities(params) { | ||
var text = params.text | ||
var searchedEntity = params.searchedEntity ?? null | ||
const payload = { | ||
@@ -123,7 +154,17 @@ 'text': text, | ||
generation(text, maxLength = null, lengthNoInput = null, | ||
endSequence = null, removeInput = null, numBeams = null, | ||
numReturnSequences = null, topK = null, topP = null, | ||
temperature = null, repetitionPenalty = null, badWords = null, | ||
removeEndSequence = null) { | ||
generation(params) { | ||
var text = params.text | ||
var maxLength = params.maxLength ?? null | ||
var lengthNoInput = params.lengthNoInput ?? null | ||
var endSequence = params.endSequence ?? null | ||
var removeInput = params.removeInput ?? null | ||
var numBeams = params.numBeams ?? null | ||
var numReturnSequences = params.numReturnSequences ?? null | ||
var topK = params.topK ?? null | ||
var topP = params.topP ?? null | ||
var temperature = params.temperature ?? null | ||
var repetitionPenalty = params.repetitionPenalty ?? null | ||
var badWords = params.badWords ?? null | ||
var removeEndSequence = params.removeEndSequence ?? null | ||
const payload = { | ||
@@ -148,3 +189,5 @@ 'text': text, | ||
gsCorrection(text) { | ||
gsCorrection(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -157,3 +200,5 @@ 'text': text | ||
imageGeneration(text) { | ||
imageGeneration(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -166,3 +211,5 @@ 'text': text | ||
intentClassification(text) { | ||
intentClassification(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -175,3 +222,5 @@ 'text': text | ||
kwKpExtraction(text) { | ||
kwKpExtraction(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -184,3 +233,5 @@ 'text': text | ||
langdetection(text) { | ||
langdetection(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -198,3 +249,5 @@ 'text': text | ||
paraphrasing(text) { | ||
paraphrasing(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -208,2 +261,5 @@ 'text': text | ||
question(question, context = null) { | ||
var question = params.question | ||
var context = params.context ?? null | ||
const payload = { | ||
@@ -217,3 +273,6 @@ 'question': question, | ||
semanticSearch(text, numResults = null) { | ||
semanticSearch() { | ||
var text = params.text | ||
var numResults = params.numResults ?? null | ||
const payload = { | ||
@@ -227,3 +286,5 @@ 'text': text, | ||
semanticSimilarity(sentences) { | ||
semanticSimilarity(params) { | ||
var sentences = params.sentences | ||
const payload = { | ||
@@ -236,3 +297,5 @@ 'sentences': sentences | ||
sentenceDependencies(text) { | ||
sentenceDependencies(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -245,3 +308,5 @@ 'text': text | ||
sentiment(text) { | ||
sentiment(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -255,2 +320,5 @@ 'text': text | ||
speechSynthesis(text, voice = null) { | ||
var text = params.text | ||
var voice = params.voice ?? null | ||
const payload = { | ||
@@ -264,3 +332,6 @@ 'text': text, | ||
summarization(text, size = null) { | ||
summarization(params) { | ||
var text = params.text | ||
var size = params.size ?? null | ||
const payload = { | ||
@@ -274,3 +345,5 @@ 'text': text, | ||
tokens(text) { | ||
tokens(params) { | ||
var text = params.text | ||
const payload = { | ||
@@ -283,3 +356,7 @@ 'text': text | ||
translation(text, source, target) { | ||
translation(params) { | ||
var text = params.text | ||
var source = params.source ?? null | ||
var target = params.target | ||
const payload = { | ||
@@ -286,0 +363,0 @@ 'text': text, |
{ | ||
"name": "nlpcloud", | ||
"version": "1.0.48", | ||
"version": "1.0.49", | ||
"description": "NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, speech synthesis, embeddings, and dependency parsing. It is ready for production, served through a REST API.\n\nThis is the Node.js client for the NLP Cloud API.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
"axios": "^0.21.4" | ||
}, | ||
@@ -36,2 +36,2 @@ "devDependencies": { | ||
"types": "./dist/index.d.ts" | ||
} | ||
} |
@@ -32,3 +32,3 @@ # Node.js Client For NLP Cloud | ||
const client = new NLPCloudClient('bart-large-cnn','4eC39HqLyjWDarjtT1zdp7dc') | ||
const client = new NLPCloudClient({model:'bart-large-cnn', token:'4eC39HqLyjWDarjtT1zdp7dc'}) | ||
@@ -61,3 +61,3 @@ client.summarization(`One month after the United States began what has become a | ||
const client = new NLPCloudClient('bart-large-cnn','4eC39HqLyjWDarjtT1zdp7dc', true) | ||
const client = new NLPCloudClient({model:'bart-large-cnn', token:'4eC39HqLyjWDarjtT1zdp7dc'}, true) | ||
@@ -90,3 +90,3 @@ client.summarization(`One month after the United States began what has become a | ||
const client = new NLPCloudClient('bart-large-cnn','4eC39HqLyjWDarjtT1zdp7dc', true, 'fra_Latn') | ||
const client = new NLPCloudClient({model:'bart-large-cnn', token:'4eC39HqLyjWDarjtT1zdp7dc', gpu:true, lang:'fra_Latn'}) | ||
@@ -136,6 +136,6 @@ client.summarization(`Sur des images aériennes, prises la veille par un vol de surveillance | ||
const client = new NLPCloudClient('<model>','<your token>') | ||
const client = new NLPCloudClient({model:'<model>', token:'<your token>'}) | ||
``` | ||
If you want to use a GPU, pass `true` as the 3rd argument. | ||
If you want to use a GPU, pass `true` as the gpu argument. | ||
@@ -145,6 +145,6 @@ ```js | ||
const client = new NLPCloudClient('<model>', '<your token>', true) | ||
const client = new NLPCloudClient({model:'<model>', token:'<your token>', gpu:true}) | ||
``` | ||
If you want to use the multilingual add-on in order to process non-English texts, set `lang='<your language code>'` as the 4th argument. For example, if you want to process French text, you should set `lang='fra_Latn'` as the 4th argument. | ||
If you want to use the multilingual add-on in order to process non-English texts, set `'<your language code>'` as the lang argument. For example, if you want to process French text, you should set `lang:'fra_Latn'`. | ||
@@ -154,6 +154,6 @@ ```js | ||
const client = new NLPCloudClient('<model>', '<your token>', false, '<your language code>') | ||
const client = new NLPCloudClient({model:'<model>', token:'<your token>', lang:'<your language code>'}) | ||
``` | ||
If you want to make asynchronous requests, pass `true` as the 4th argument. | ||
If you want to make asynchronous requests, pass `true` as the async argument. | ||
@@ -163,3 +163,3 @@ ```js | ||
const client = new NLPCloudClient('<model>', '<your token>', false, '<your language code>', true) | ||
const client = new NLPCloudClient({model:'<model>', token:'<your token>', async:true) | ||
``` | ||
@@ -178,3 +178,3 @@ | ||
```js | ||
client.adGeneration(['keyword 1', 'keyword 2', ...]) | ||
client.adGeneration({keywords:['keyword 1', 'keyword 2', ...]}) | ||
``` | ||
@@ -191,3 +191,3 @@ | ||
```js | ||
client.asr('Your url') | ||
client.asr({url:'Your url'}) | ||
``` | ||
@@ -204,3 +204,3 @@ | ||
```js | ||
client.chatbot('<Your input>') | ||
client.chatbot({text:'<Your input>'}) | ||
``` | ||
@@ -217,3 +217,3 @@ | ||
```js | ||
client.classification('<Your block of text>', ['label 1', 'label 2', ...]) | ||
client.classification({text:'<Your block of text>', labels:['label 1', 'label 2', ...]}) | ||
``` | ||
@@ -226,3 +226,3 @@ | ||
```js | ||
client.codeGeneration('<Your instruction>') | ||
client.codeGeneration({instruction:'<Your instruction>'}) | ||
``` | ||
@@ -235,3 +235,3 @@ | ||
```js | ||
client.dependencies('<Your block of text>') | ||
client.dependencies({text:'<Your block of text>'}) | ||
``` | ||
@@ -244,3 +244,3 @@ | ||
```js | ||
client.embeddings(['<Text 1>', '<Text 2>', '<Text 3>', ...]) | ||
client.embeddings({sentences:['<Text 1>', '<Text 2>', '<Text 3>', ...]}) | ||
``` | ||
@@ -255,3 +255,3 @@ | ||
```js | ||
client.entities('<Your block of text>') | ||
client.entities({text:'<Your block of text>'}) | ||
``` | ||
@@ -278,3 +278,3 @@ | ||
```js | ||
client.generation('<Your input text>') | ||
client.generation({text:'<Your input text>'}) | ||
``` | ||
@@ -287,3 +287,3 @@ | ||
```js | ||
client.gsCorrection('<The text you want to correct>') | ||
client.gsCorrection({text:'<The text you want to correct>'}) | ||
``` | ||
@@ -296,3 +296,3 @@ | ||
```js | ||
client.imageGeneration('<Your text instruction>') | ||
client.imageGeneration({text:'<Your text instruction>'}) | ||
``` | ||
@@ -305,3 +305,3 @@ | ||
```js | ||
client.intentClassification('<The text you want to analyze>') | ||
client.intentClassification({text:'<The text you want to analyze>'}) | ||
``` | ||
@@ -314,3 +314,3 @@ | ||
```js | ||
client.kwKpExtraction('<The text you want to analyze>') | ||
client.kwKpExtraction({text:'<The text you want to analyze>'}) | ||
``` | ||
@@ -323,3 +323,3 @@ | ||
```js | ||
client.langdetection('<The text you want to analyze>') | ||
client.langdetection({text:'<The text you want to analyze>'}) | ||
``` | ||
@@ -343,3 +343,3 @@ | ||
```js | ||
client.question('<Your question>','<Your context>') | ||
client.question({question:'<Your question>', context:'<Your context>'}) | ||
``` | ||
@@ -362,3 +362,3 @@ | ||
```python | ||
client.semanticSimilarity(['<Block of text 1>', '<Block of text 2>']) | ||
client.semanticSimilarity({sentences:['<Block of text 1>', '<Block of text 2>']}) | ||
``` | ||
@@ -373,3 +373,3 @@ | ||
```js | ||
client.sentenceDependencies('<Your block of text>') | ||
client.sentenceDependencies({text:'<Your block of text>'}) | ||
``` | ||
@@ -382,3 +382,3 @@ | ||
```js | ||
client.sentiment('<Your block of text>') | ||
client.sentiment({text:'<Your block of text>'}) | ||
``` | ||
@@ -391,3 +391,3 @@ | ||
```js | ||
client.speechSynthesis("<Your block of text>") | ||
client.speechSynthesis({text:"<Your block of text>"}) | ||
``` | ||
@@ -402,3 +402,3 @@ | ||
```js | ||
client.summarization('<Your text to summarize>') | ||
client.summarization({text:'<Your text to summarize>'}) | ||
``` | ||
@@ -411,3 +411,3 @@ | ||
```js | ||
client.paraphrasing('<Your text to paraphrase>') | ||
client.paraphrasing({text:'<Your text to paraphrase>'}) | ||
``` | ||
@@ -420,3 +420,3 @@ | ||
```js | ||
client.tokens('<Your block of text>') | ||
client.tokens({text:'<Your block of text>'}) | ||
``` | ||
@@ -429,3 +429,3 @@ | ||
```js | ||
client.translation('<Your text to translate>') | ||
client.translation({text:'<Your text to translate>'}) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35797
606
1
Updatedaxios@^0.21.4