Skip to content

Commit 00d83fe

Browse files
docs(readme): update and remove refs to deprecated services
1 parent 2e28441 commit 00d83fe

File tree

2 files changed

+41
-117
lines changed

2 files changed

+41
-117
lines changed

README.md

Lines changed: 37 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ npm install ibm-watson
2727
## Usage
2828

2929
```js
30-
import DiscoveryV1 from 'ibm-watson/discovery/v1';
30+
import AssistantV2 from 'ibm-watson/assistant/v2';
3131
import { IamAuthenticator } from 'ibm-watson/auth';
3232

33-
const discoveryClient = new DiscoveryV1({
33+
const assistantClient = new AssistantV2({
3434
authenticator: new IamAuthenticator({ apikey: '{apikey}' }),
3535
version: '{version}',
3636
});
@@ -55,7 +55,8 @@ Watson services are migrating to token-based Identity and Access Management (IAM
5555

5656
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
5757
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
58-
- If you're using a Watson service on ICP, you'll need to authenticate in [a specific way](#icp).
58+
- If you are using a Watson service on ICP, you will need to authenticate in [a specific way](#icp).
59+
- If you are using a Watson service on AWS, you will need to authenticate using [mcsp](#mcsp).
5960

6061
Authentication is accomplished using dedicated Authenticators for each authentication scheme. Import authenticators from `ibm-watson/auth` or rely on externally-configured credentials which will be read from a credentials file or environment variables.
6162

@@ -89,32 +90,26 @@ The file downloaded will be called `ibm-credentials.env`. This is the name the S
8990
- Your system's home directory
9091
- Your current working directory (the directory Node is executed from)
9192

92-
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
93+
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Assistant instance, you just need to do the following:
9394

9495
```js
95-
const DiscoveryV1 = require('ibm-watson/discovery/v1');
96-
const discovery = new DiscoveryV1({ version: '2019-02-01' });
96+
const AssistantV2 = require('ibm-watson/assistant/v2');
97+
const assistant = new AssistantV2({ version: '2024-08-25' });
9798
```
9899

99100
And that's it!
100101

101102
If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services.
102103

103-
**Special Note**: Due to legacy issues in Assistant V1 and V2 as well as Visual Recognition V3 and V4, the following parameter `serviceName` must be added when creating the service object:
104+
**Special Note**: Due to legacy issues in Assistant V1 and V2, the following parameter `serviceName` must be added when creating the service object:
104105
```js
105-
const AssistantV1 = require('ibm-watson/assistant/v1');
106-
const assistant = new AssistantV1({
107-
version: '2020-04-01',
106+
const AssistantV2 = require('ibm-watson/assistant/v2');
107+
const assistant = new AssistantV2({
108+
version: '2024-08-25',
108109
serviceName: 'assistant',
109110
})
110111
```
111-
```js
112-
const VisualRecognitionV3 = require('ibm-watson/visual-recognition/v3');
113-
const assistant = new VisualRecognitionV3({
114-
version: '2018-03-19',
115-
serviceName: 'visual-recognition',
116-
})
117-
```
112+
118113
It is worth noting that if you are planning to rely on VCAP_SERVICES for authentication then the `serviceName` parameter **MUST** be removed otherwise VCAP_SERVICES will not be able to authenticate you. See [Cloud Authentication Prioritization](#cloud-authentication-prioritization) for more details.
119114

120115
If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that:
@@ -154,7 +149,7 @@ const authenticator = new McspAuthenticator({
154149
url: 'token_service_endpoint',
155150
apikey: 'apikey',
156151
})
157-
const assistant = AssistantV2(version='2023-06-15',
152+
const assistant = AssistantV2(version='2024-08-25',
158153
authenticator=authenticator)
159154
assistant.setServiceUrl('<url_as_per_region>')
160155
```
@@ -170,27 +165,27 @@ When uploading your application to IBM Cloud there is a certain priority Watson
170165
You can set or reset the base URL after constructing the client instance using the `setServiceUrl` method:
171166

172167
```js
173-
const DiscoveryV1 = require('ibm-watson/discovery/v1');
168+
const AssistantV2 = require('ibm-watson/assistant/v2');
174169

175-
const discovery = DiscoveryV1({
170+
const assistant = AssistantV2({
176171
/* authenticator, version, etc... */
177172
});
178173

179-
discovery.setServiceUrl('<new url>');
174+
assistant.setServiceUrl('<new url>');
180175
```
181176

182177
## Promises
183178

184179
All SDK methods are asynchronous, as they are making network requests to Watson services. To handle receiving the data from these requests, the SDK offers support with Promises.
185180
```js
186-
const DiscoveryV1 = require('ibm-watson/discovery/v1');
181+
const AssistantV2 = require('ibm-watson/assistant/v2');
187182

188-
const discovery = new DiscoveryV1({
183+
const assistant = new AssistantV2({
189184
/* authenticator, version, serviceUrl, etc... */
190185
});
191186

192187
// using Promises
193-
discovery.listEnvironments()
188+
assistant.listAssistants()
194189
.then(body => {
195190
console.log(JSON.stringify(body, null, 2));
196191
})
@@ -199,8 +194,8 @@ discovery.listEnvironments()
199194
});
200195

201196
// using Promises provides the ability to use async / await
202-
async function callDiscovery() { // note that callDiscovery also returns a Promise
203-
const body = await discovery.listEnvironments();
197+
async function callAssistant() { // note that callAssistant also returns a Promise
198+
const body = await assistant.listAssistants();
204199
}
205200
```
206201

@@ -211,7 +206,7 @@ Custom headers can be passed with any request. Each method has an optional param
211206
For example, this is how you can pass in custom headers to Watson Assistant service. In this example, the `'custom'` value for `'Accept-Language'` will override the default header for `'Accept-Language'`, and the `'Custom-Header'` while not overriding the default headers, will additionally be sent with the request.
212207

213208
```js
214-
const assistant = new watson.AssistantV1({
209+
const assistant = new watson.AssistantV2({
215210
/* authenticator, version, serviceUrl, etc... */
216211
});
217212

@@ -238,7 +233,7 @@ The SDK now returns the full HTTP response by default for each method.
238233
Here is an example of how to access the response headers for Watson Assistant:
239234

240235
```js
241-
const assistant = new AssistantV1({
236+
const assistant = new AssistantV2({
242237
/* authenticator, version, serviceUrl, etc... */
243238
});
244239

@@ -261,11 +256,11 @@ assistant.message(params).then(
261256
```
262257

263258
### Global Transaction ID
264-
Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. Together the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
259+
Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. Together with the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
265260

266261
#### HTTP Example
267262
```js
268-
const assistant = new AssistantV1({
263+
const assistant = new AssistantV2({
269264
/* authenticator, version, serviceUrl, etc... */
270265
});
271266

@@ -296,7 +291,7 @@ recognizeStream.getTransactionId().then(
296291
However, the transaction ID isn't available when the API doesn't return a response for some reason. In that case, you can set your own transaction ID in the request. For example, replace `<my-unique-transaction-id>` in the following example with a unique transaction ID.
297292

298293
```js
299-
const assistant = new AssistantV1({
294+
const assistant = new AssistantV2({
300295
/* authenticator, version, serviceUrl, etc... */
301296
});
302297

@@ -338,7 +333,7 @@ To use the SDK (which makes HTTPS requests) behind an HTTP proxy, a special tunn
338333
See this example configuration:
339334
```js
340335
const tunnel = require('tunnel');
341-
const AssistantV1 = require('ibm-watson/assistant/v1');
336+
const AssistantV2 = require('ibm-watson/assistant/v2');
342337
const { IamAuthenticator } = require('ibm-watson/auth');
343338

344339
const httpsAgent = tunnel.httpsOverHttp({
@@ -348,13 +343,13 @@ const httpsAgent = tunnel.httpsOverHttp({
348343
},
349344
});
350345

351-
const assistant = new AssistantV1({
346+
const assistant = new AssistantV2({
352347
authenticator: new IamAuthenticator({
353348
apikey: 'fakekey-1234'
354349
httpsAgent, // not necessary if using Basic or BearerToken authentication
355350
proxy: false,
356351
}),
357-
version: '2020-01-28',
352+
version: '2024-08-25',
358353
httpsAgent,
359354
proxy: false,
360355
});
@@ -363,21 +358,21 @@ const assistant = new AssistantV1({
363358
### Sending custom certificates
364359
To send custom certificates as a security measure in your request, use the `cert`, `key`, and/or `ca` properties of the HTTPS Agent. See [this documentation](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options) for more information about the options. Note that the entire contents of the file must be provided - not just the file name.
365360
```js
366-
const AssistantV1 = require('ibm-watson/assistant/v1');
361+
const AssistantV2 = require('ibm-watson/assistant/v2');
367362
const { IamAuthenticator } = require('ibm-watson/auth');
368363

369364
const certFile = fs.readFileSync('./my-cert.pem');
370365
const keyFile = fs.readFileSync('./my-key.pem');
371366

372-
const assistant = new AssistantV1({
367+
const assistant = new AssistantV2({
373368
authenticator: new IamAuthenticator({
374369
apikey: 'fakekey-1234',
375370
httpsAgent: new https.Agent({
376371
key: keyFile,
377372
cert: certFile,
378373
})
379374
}),
380-
version: '2019-02-28',
375+
version: '2024-08-25',
381376
httpsAgent: new https.Agent({
382377
key: keyFile,
383378
cert: certFile,
@@ -392,7 +387,7 @@ The HTTP client can be configured to disable SSL verification. **Note that this
392387
To do this, set `disableSslVerification` to `true` in the service constructor and/or authenticator constructor, like below:
393388

394389
```js
395-
const discovery = new DiscoveryV1({
390+
const assistant = new AssistantV2({
396391
serviceUrl: '<service_url>',
397392
version: '<version-date>',
398393
authenticator: new IamAuthenticator({ apikey: '<apikey>', disableSslVerification: true }), // this will disable SSL verification for requests to the token endpoint
@@ -407,8 +402,6 @@ To see all possible https agent configuration options go to this [link](https://
407402

408403
You can find links to the documentation at https://cloud.ibm.com/developer/watson/documentation. Find the service that you're interested in, click **API reference**, and then select the **Node** tab.
409404

410-
There are also auto-generated JSDocs available at http://watson-developer-cloud.github.io/node-sdk/master/
411-
412405
## Questions
413406

414407
If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+node.js).
@@ -452,13 +445,13 @@ Use the [Assistant][assistant] service to determine the intent of a message.
452445
Note: You must first create a workspace via IBM Cloud. See [the documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-index#about) for details.
453446

454447
```js
455-
const AssistantV1 = require('ibm-watson/assistant/v1');
448+
const AssistantV2 = require('ibm-watson/assistant/v2');
456449
const { IamAuthenticator } = require('ibm-watson/auth');
457450

458-
const assistant = new AssistantV1({
451+
const assistant = new AssistantV2({
459452
authenticator: new IamAuthenticator({ apikey: '<apikey>' }),
460453
serviceUrl: 'https://api.us-south.assistant.watson.cloud.ibm.com',
461-
version: '2018-02-16'
454+
version: '2024-08-25'
462455
});
463456

464457
assistant.message(
@@ -501,73 +494,6 @@ discovery.query(
501494
console.log(err);
502495
});
503496
```
504-
### Discovery v1
505-
506-
Use the [Discovery Service][discovery] to search and analyze structured and unstructured data.
507-
508-
```js
509-
const DiscoveryV1 = require('ibm-watson/discovery/v1');
510-
const { IamAuthenticator } = require('ibm-watson/auth');
511-
512-
const discovery = new DiscoveryV1({
513-
authenticator: new IamAuthenticator({ apikey: '<apikey>' }),
514-
serviceUrl: 'https://api.us-south.discovery.watson.cloud.ibm.com',
515-
version: '2017-09-01'
516-
});
517-
518-
discovery.query(
519-
{
520-
environmentId: '<environment_id>',
521-
collectionId: '<collection_id>',
522-
query: 'my_query'
523-
})
524-
.then(response => {
525-
console.log(JSON.stringify(response.result, null, 2));
526-
})
527-
.catch(err => {
528-
console.log(err);
529-
});
530-
```
531-
532-
### Language Translator
533-
534-
Translate text from one language to another or idenfity a language using the [Language Translator][language_translator] service.
535-
536-
```js
537-
const LanguageTranslatorV3 = require('ibm-watson/language-translator/v3');
538-
const { IamAuthenticator } = require('ibm-watson/auth');
539-
540-
const languageTranslator = new LanguageTranslatorV3({
541-
authenticator: new IamAuthenticator({ apikey: '<apikey>' }),
542-
serviceUrl: 'https://api.us-south.language-translator.watson.cloud.ibm.com',
543-
version: 'YYYY-MM-DD',
544-
});
545-
546-
languageTranslator.translate(
547-
{
548-
text: 'A sentence must have a verb',
549-
source: 'en',
550-
target: 'es'
551-
})
552-
.then(response => {
553-
console.log(JSON.stringify(response.result, null, 2));
554-
})
555-
.catch(err => {
556-
console.log('error: ', err);
557-
});
558-
559-
languageTranslator.identify(
560-
{
561-
text:
562-
'The language translator service takes text input and identifies the language used.'
563-
})
564-
.then(response => {
565-
console.log(JSON.stringify(response.result, null, 2));
566-
})
567-
.catch(err => {
568-
console.log('error: ', err);
569-
});
570-
```
571497

572498

573499
### Natural Language Understanding
@@ -689,7 +615,7 @@ The SDK always expects an authenticator to be passed in. To make an unautuhentic
689615
const watson = require('ibm-watson');
690616
const { NoAuthAuthenticator } = require('ibm-watson/auth');
691617

692-
const assistant = new watson.AssistantV1({
618+
const assistant = new watson.AssistantV2({
693619
authenticator: new NoAuthAuthenticator(),
694620
});
695621
```
@@ -727,21 +653,15 @@ See [CONTRIBUTING](https://github.com/watson-developer-cloud/node-sdk/blob/maste
727653
We love to highlight cool open-source projects that use this SDK! If you'd like to get your project added to the list, feel free to make an issue linking us to it.
728654
- [Watson Speech to Text Demo App](https://github.com/watson-developer-cloud/speech-to-text-nodejs)
729655
- [Watson Assistant Demo App](https://github.com/watson-developer-cloud/assistant-demo)
730-
- [Virtual TJBot Node-RED Nodes](https://github.com/jeancarl/node-red-contrib-virtual-tjbot)
731656
- [CLI tool for Watson Assistant](https://github.com/Themandunord/IWAC)
732-
- [CLI tool for Watson Visual Recognition](https://github.com/boneskull/puddlenuts)
733657

734658
## License
735659
This library is licensed under Apache 2.0. Full license text is available in
736660
[COPYING][license].
737661

738662
[assistant]: https://www.ibm.com/cloud/watson-assistant/
739663
[discovery]: https://www.ibm.com/cloud/watson-discovery
740-
[personality_insights]: https://www.ibm.com/watson/services/personality-insights/
741-
[visual_recognition]: https://www.ibm.com/watson/services/visual-recognition/
742-
[tone_analyzer]: https://www.ibm.com/watson/services/tone-analyzer/
743664
[text_to_speech]: https://www.ibm.com/watson/services/text-to-speech/
744665
[speech_to_text]: https://www.ibm.com/watson/services/speech-to-text/
745-
[language_translator]: https://www.ibm.com/watson/services/language-translator/
746666
[examples]: https://github.com/watson-developer-cloud/node-sdk/tree/master/examples
747667
[ibm-cloud-onboarding]: http://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Node

lib/recognize-stream.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class RecognizeStream extends Duplex {
8686
* @param {string} [options.contentType] - The format (MIME type) of the audio
8787
* @param {number} [options.customizationWeight] - Tell the service how much weight to give to words from the custom language model compared to those from the base model for the current request
8888
* @param {number} [options.inactivityTimeout] - The time in seconds after which, if only silence (no speech) is detected in the audio, the connection is closed (default=30)
89+
* @param {boolean} [options.interimResults] - If true, the service returns interim results as a stream of JSON SpeechRecognitionResults objects (default=false)
8990
* @param {string[]} [options.keywords] - An array of keyword strings to spot in the audio
9091
* @param {number} [options.keywordsThreshold] - A confidence value that is the lower bound for spotting a keyword
9192
* @param {number} [options.maxAlternatives] - The maximum number of alternative transcripts that the service is to return (default=1)
@@ -104,6 +105,7 @@ class RecognizeStream extends Duplex {
104105
* @param {boolean} [options.splitTranscriptAtPhraseEnd] - If `true`, directs the service to split the transcript into multiple final results based on semantic features of the input
105106
* @param {number} [options.speechDetectorSensitivity] - The sensitivity of speech activity detection that the service is to perform
106107
* @param {number} [options.backgroundAudioSuppression] - The level to which the service is to suppress background audio based on its volume to prevent it from being transcribed as speech
108+
* @param {boolean} [params.lowLatency] - If `true` for next-generation `Multimedia` and `Telephony` models that support low latency, directs the service to produce results even more quickly than it usually does
107109
* @constructor
108110
*/
109111
constructor(options: RecognizeStream.Options) {
@@ -166,6 +168,7 @@ class RecognizeStream extends Duplex {
166168
'timestamps',
167169
'word_confidence',
168170
'content-type',
171+
'interim_results',
169172
'keywords',
170173
'keywords_threshold',
171174
'max_alternatives',
@@ -179,6 +182,7 @@ class RecognizeStream extends Duplex {
179182
'split_transcript_at_phrase_end',
180183
'speech_detector_sensitivity',
181184
'background_audio_suppression',
185+
'low_latency'
182186
];
183187
const openingMessage = processUserParameters(options, openingMessageParamsAllowed);
184188
openingMessage.action = 'start';

0 commit comments

Comments
 (0)