-
Notifications
You must be signed in to change notification settings - Fork 654
fix: update dependencies and examples #1036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ed59bce
bafb6cf
71864eb
60c8139
5c03d60
3f0c2cb
1eefbbd
df4e02d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| module.exports = { | ||
| "parserOptions": { "ecmaVersion": 6 }, | ||
| "rules": { | ||
| "no-console": "off", | ||
| "node/no-missing-require": "off", | ||
| "require-jsdoc": "off", | ||
| "valid-jsdoc": "off", | ||
| "no-process-exit": "off", | ||
| "prefer-const": "off", | ||
| "no-var": "off" | ||
| } | ||
| parserOptions: { ecmaVersion: 6 }, | ||
| rules: { | ||
| 'no-console': 'off', | ||
| 'node/no-missing-require': 'off', | ||
| 'require-jsdoc': 'off', | ||
| 'valid-jsdoc': 'off', | ||
| 'no-process-exit': 'off', | ||
| 'prefer-const': 'off', | ||
| 'no-var': 'off', | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,25 +6,25 @@ var AssistantV1 = require('ibm-watson/assistant/v1'); | |
| * Instantiate the Watson Assistant Service | ||
| */ | ||
| var assistant = new AssistantV1({ | ||
| username: process.env.ASSISTANT_USERNAME || '<assistant_username>', | ||
| password: process.env.ASSISTANT_PASSWORD || '<assistant_password>', | ||
| version: '2018-02-16' | ||
| // See: https://github.com/watson-developer-cloud/node-sdk#authentication | ||
| // iam_apikey: 'INSERT YOUR IAM API KEY HERE', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for the latest version, this should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this mean we need to add an authentication field? |
||
| version: '2020-04-30', | ||
| }); | ||
|
|
||
| /** | ||
| * Calls the assistant message api. | ||
| * returns a promise | ||
| */ | ||
| var message = function(text, context) { | ||
| var message = function (text, context) { | ||
| var payload = { | ||
| workspace_id: process.env.WORKSPACE_ID || '<workspace_id>', | ||
| input: { | ||
| text: text | ||
| text: text, | ||
| }, | ||
| context: context | ||
| context: context, | ||
| }; | ||
| return new Promise((resolve, reject) => | ||
| assistant.message(payload, function(err, data) { | ||
| assistant.message(payload, function (err, data) { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
|
|
@@ -49,9 +49,7 @@ message('first message', undefined) | |
| }) | ||
| .then(response2 => { | ||
| console.log(JSON.stringify(response2, null, 2), '\n--------'); | ||
| console.log( | ||
| 'Note that the two reponses should have the same context.conversation_id' | ||
| ); | ||
| console.log('Note that the two reponses should have the same context.conversation_id'); | ||
| }) | ||
| .catch(err => { | ||
| // APPLICATION-SPECIFIC CODE TO PROCESS THE ERROR | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,6 @@ | |
| * Service credentials can be provided directly in this file, or can be saved to a .env file located in the | ||
| * same directory. | ||
| * | ||
| * Requirements: | ||
| * 1. Tone Analyzer Service instance: | ||
| * - https://cloud.ibm.com/catalog/services/tone-analyzer | ||
| * - credentials for this service to be provided below in tone_analyzer variable | ||
| * - replace <tone_analyzer_username> and <tone_analyzer_password> | ||
| * 2. Assistant Service instance: | ||
| * - https://cloud.ibm.com/catalog/services/watson-assistant | ||
| * - credentials for this service to be provided below in the assistant variable | ||
| * - replace <assistant_username> and <assistant_password> | ||
| * 3. Workspace id: | ||
| * - a workspace containing intents, entities and dialog nodes must be created using the tool | ||
| * available through the IBM Cloud Assistant Service. Details are available at | ||
| * https://github.com/watson-developer-cloud/assistant-simple#workspace | ||
| * - replace <workspace_id> in the payload variable | ||
| * | ||
| * Run the code using the command: | ||
| * node tone_assistant_integration.v1.js | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
@@ -39,18 +22,18 @@ require('dotenv').config({ silent: true }); | |
| * Instantiate the Watson Assistant Service | ||
| */ | ||
| var assistant = new AssistantV1({ | ||
| username: process.env.ASSISTANT_USERNAME || '<assistant_username>', | ||
| password: process.env.ASSISTANT_PASSWORD || '<assistant_password>', | ||
| version: '2017-05-26' | ||
| // See: https://github.com/watson-developer-cloud/node-sdk#authentication | ||
| // iam_apikey: 'INSERT YOUR IAM API KEY HERE', | ||
| version: '2020-04-30', | ||
| }); | ||
|
|
||
| /** | ||
| * Instantiate the Watson Tone Analyzer Service | ||
| */ | ||
| var toneAnalyzer = new ToneAnalyzerV3({ | ||
| username: process.env.TONE_ANALYZER_USERNAME || '<tone_analyzer_username>', | ||
| password: process.env.TONE_ANALYZER_PASSWORD || '<tone_analyzer_password>', | ||
| version: '2017-09-21' | ||
| // See: https://github.com/watson-developer-cloud/node-sdk#authentication | ||
| // iam_apikey: 'INSERT YOUR IAM API KEY HERE', | ||
| version: '2017-09-21', | ||
| }); | ||
|
|
||
| /** | ||
|
|
@@ -66,8 +49,8 @@ var maintainToneHistoryInContext = true; | |
| var payload = { | ||
| workspace_id: process.env.WORKSPACE_ID || '<workspace_id>', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The keys are now camel case: |
||
| input: { | ||
| text: 'I am not happy today :(' | ||
| } | ||
| text: 'I am not happy today :(', | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -84,12 +67,8 @@ function invokeToneAssistant(payload, maintainToneHistoryInContext) { | |
| tone_detection | ||
| .invokeToneAsync(payload, toneAnalyzer) | ||
| .then(tone => { | ||
| tone_detection.updateUserTone( | ||
| payload, | ||
| tone, | ||
| maintainToneHistoryInContext | ||
| ); | ||
| assistant.message(payload, function(err, data) { | ||
| tone_detection.updateUserTone(payload, tone, maintainToneHistoryInContext); | ||
| assistant.message(payload, function (err, data) { | ||
| if (err) { | ||
| // APPLICATION-SPECIFIC CODE TO PROCESS THE ERROR | ||
| // FROM ASSISTANT SERVICE | ||
|
|
@@ -101,7 +80,7 @@ function invokeToneAssistant(payload, maintainToneHistoryInContext) { | |
| } | ||
| }); | ||
| }) | ||
| .catch(function(err) { | ||
| .catch(function (err) { | ||
| console.log(JSON.stringify(err, null, 2)); | ||
| }); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess our lint config should follow the lint rules, huh? 👍