Socket
Socket
Sign inDemoInstall

node-wit

Package Overview
Dependencies
Maintainers
5
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-wit - npm Package Compare versions

Comparing version 6.5.1 to 6.6.0

lib/lib/config.js

2

lib/config.js

@@ -6,4 +6,4 @@ /**

module.exports = {
DEFAULT_API_VERSION: 20220801,
DEFAULT_API_VERSION: 20230215,
DEFAULT_WIT_URL: 'https://api.wit.ai',
};

@@ -16,2 +16,3 @@ /**

const LIVE_UNDERSTANDING_API_VERSION = 20220608;
const MULTI_RESPONSES_API_VERSION = 20230215;

@@ -49,3 +50,3 @@ class Wit extends EventEmitter {

const {apiVersion, headers, logger, proxy, witURL} = this.config;
const {actions, apiVersion, headers, logger, proxy, witURL} = this.config;

@@ -65,2 +66,4 @@ const params = {

const multi_responses_enabled = apiVersion >= MULTI_RESPONSES_API_VERSION;
const req = fetch(fullURL, {

@@ -79,6 +82,6 @@ body,

.then(
response =>
resp =>
new Promise((resolve, reject) => {
logger.debug('status', response.status);
const bodyStream = response.body;
logger.debug('status', resp.status);
const bodyStream = resp.body;

@@ -93,3 +96,4 @@ bodyStream.on('readable', () => {

for (const rsp of parseResponse(contents)) {
const {error, is_final, text} = rsp;
const {action, context_map, error, is_final, response, text} =
rsp;

@@ -101,2 +105,19 @@ // Live transcription

}
// Multi-responses
if (
multi_responses_enabled &&
!(error || is_final) &&
(action || response)
) {
if (response) {
logger.debug('[converse] partialResponse:', response);
this.emit('response', response);
}
if (action) {
logger.debug('[converse] got partial action:', action);
runAction(logger, actions, action, context_map);
}
}
}

@@ -130,3 +151,3 @@ });

const {apiVersion, headers, logger, proxy, witURL} = this.config;
const {actions, apiVersion, headers, logger, proxy, witURL} = this.config;

@@ -152,4 +173,52 @@ const params = {

return fetch(fullURL, {body: JSON.stringify(body), method, headers, proxy})
.then(response => Promise.all([response.json(), response.status]))
const req = fetch(fullURL, {
body: JSON.stringify(body),
method,
headers,
proxy,
});
// Multi-responses
if (apiVersion >= MULTI_RESPONSES_API_VERSION) {
const _partialResponses = req
.then(
resp =>
new Promise((resolve, reject) => {
logger.debug('status', resp.status);
const bodyStream = resp.body;
bodyStream.on('readable', () => {
let chunk;
let contents = '';
while (null !== (chunk = bodyStream.read())) {
contents += chunk.toString();
}
for (const rsp of parseResponse(contents)) {
const {action, context_map, error, is_final, response} = rsp;
if (!(error || is_final) && (action || response)) {
if (response) {
logger.debug('[event] partialResponse:', response);
this.emit('response', response);
}
if (action) {
logger.debug('[event] got partial action:', action);
runAction(logger, actions, action, context_map);
}
}
}
});
}),
)
.catch(e =>
logger.error('[event] could not parse partial response', e),
);
}
return req
.then(response => Promise.all([response.text(), response.status]))
.then(([contents, status]) => ([parseResponse(contents).pop(), status]))
.catch(e => e)
.then(makeWitResponseHandler(logger, 'event'));

@@ -375,3 +444,3 @@ }

if (typeof voice !== 'string') {
throw new Error('Please provide a voice input. (string)');
throw new Error('Please provide a voice input (string).');
}

@@ -378,0 +447,0 @@

{
"name": "node-wit",
"version": "6.5.1",
"version": "6.6.0",
"description": "Wit.ai Node.js SDK",

@@ -12,3 +12,4 @@ "keywords": [

"nlp",
"automation"
"automation",
"composer"
],

@@ -15,0 +16,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc