Skip to content

Commit 7f7d96f

Browse files
committed
feat(assistantv2): assistant v2 generated with new spec
Added several new properties to models BREAKING CHANGE: MessageOutputDebug - renamed DialogNodesVisited to DialogNodeVisited; RuntimeEntity - removed optional metadata property
1 parent 5c6e9db commit 7f7d96f

File tree

2 files changed

+129
-23
lines changed

2 files changed

+129
-23
lines changed

assistant/v2.ts

Lines changed: 110 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2021.
2+
* (C) Copyright IBM Corp. 2018, 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ class AssistantV2 extends BaseService {
4646
static DEFAULT_SERVICE_NAME: string = 'conversation';
4747

4848
/** Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is
49-
* `2021-06-14`.
49+
* `2021-11-27`.
5050
*/
5151
version: string;
5252

@@ -55,7 +55,7 @@ class AssistantV2 extends BaseService {
5555
*
5656
* @param {Object} options - Options for the service.
5757
* @param {string} options.version - Release date of the API version you want to use. Specify dates in YYYY-MM-DD
58-
* format. The current version is `2021-06-14`.
58+
* format. The current version is `2021-11-27`.
5959
* @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions.
6060
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
6161
* @param {string} [options.serviceName] - The name of the service to configure
@@ -620,7 +620,7 @@ namespace AssistantV2 {
620620
/** Options for the `AssistantV2` constructor. */
621621
export interface Options extends UserOptions {
622622
/** Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is
623-
* `2021-06-14`.
623+
* `2021-11-27`.
624624
*/
625625
version: string;
626626
}
@@ -887,8 +887,8 @@ namespace AssistantV2 {
887887
input?: MessageInput;
888888
}
889889

890-
/** DialogNodesVisited. */
891-
export interface DialogNodesVisited {
890+
/** An objects containing detailed diagnostic information about a dialog node that was triggered during processing of the input message. */
891+
export interface DialogNodeVisited {
892892
/** A dialog node that was triggered during processing of the input message. */
893893
dialog_node?: string;
894894
/** The title of the dialog node. */
@@ -969,25 +969,29 @@ namespace AssistantV2 {
969969

970970
/** MessageContext. */
971971
export interface MessageContext {
972-
/** Session context data that is shared by all skills used by the Assistant. */
972+
/** Session context data that is shared by all skills used by the assistant. */
973973
global?: MessageContextGlobal;
974974
/** Information specific to particular skills used by the assistant.
975975
*
976976
* **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog
977977
* skill used by the assistant.
978978
*/
979979
skills?: JsonObject;
980+
/** An object containing context data that is specific to particular integrations. For more information, see the
981+
* [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations).
982+
*/
983+
integrations?: JsonObject;
980984
}
981985

982-
/** Session context data that is shared by all skills used by the Assistant. */
986+
/** Session context data that is shared by all skills used by the assistant. */
983987
export interface MessageContextGlobal {
984988
/** Built-in system properties that apply to all skills used by the assistant. */
985989
system?: MessageContextGlobalSystem;
986990
/** The session ID. */
987991
session_id?: string;
988992
}
989993

990-
/** Session context data that is shared by all skills used by the Assistant. */
994+
/** Session context data that is shared by all skills used by the assistant. */
991995
export interface MessageContextGlobalStateless {
992996
/** Built-in system properties that apply to all skills used by the assistant. */
993997
system?: MessageContextGlobalSystem;
@@ -1047,9 +1051,11 @@ namespace AssistantV2 {
10471051
* conversation (such as a change to a skill the assistant uses).
10481052
*/
10491053
state?: string;
1054+
/** For internal use only. */
1055+
skip_user_input?: boolean;
10501056
}
10511057

1052-
/** Contains information specific to a particular skill used by the Assistant. The property name must be the same as the name of the skill (for example, `main skill`). */
1058+
/** Contains information specific to a particular skill used by the assistant. The property name must be the same as the name of the skill (for example, `main skill`). */
10531059
export interface MessageContextSkill {
10541060
/** Arbitrary variables that can be read and written by a particular skill. */
10551061
user_defined?: JsonObject;
@@ -1071,14 +1077,18 @@ namespace AssistantV2 {
10711077

10721078
/** MessageContextStateless. */
10731079
export interface MessageContextStateless {
1074-
/** Session context data that is shared by all skills used by the Assistant. */
1080+
/** Session context data that is shared by all skills used by the assistant. */
10751081
global?: MessageContextGlobalStateless;
10761082
/** Information specific to particular skills used by the assistant.
10771083
*
10781084
* **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog
10791085
* skill used by the assistant.
10801086
*/
10811087
skills?: JsonObject;
1088+
/** An object containing context data that is specific to particular integrations. For more information, see the
1089+
* [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations).
1090+
*/
1091+
integrations?: JsonObject;
10821092
}
10831093

10841094
/** An input object that includes the input text. */
@@ -1103,10 +1113,24 @@ namespace AssistantV2 {
11031113
entities?: RuntimeEntity[];
11041114
/** For internal use only. */
11051115
suggestion_id?: string;
1116+
/** An array of multimedia attachments to be sent with the message.
1117+
*
1118+
* **Note:** Attachments are not processed by the assistant itself, but can be sent to external services by
1119+
* webhooks.
1120+
*/
1121+
attachments?: MessageInputAttachment[];
11061122
/** Optional properties that control how the assistant responds. */
11071123
options?: MessageInputOptions;
11081124
}
11091125

1126+
/** A reference to a media file to be sent as an attachment with the message. */
1127+
export interface MessageInputAttachment {
1128+
/** The URL of the media file. */
1129+
url: string;
1130+
/** The media content type (such as a MIME type) of the attachment. */
1131+
media_type?: string;
1132+
}
1133+
11101134
/** Optional properties that control how the assistant responds. */
11111135
export interface MessageInputOptions {
11121136
/** Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes.
@@ -1195,6 +1219,12 @@ namespace AssistantV2 {
11951219
entities?: RuntimeEntity[];
11961220
/** For internal use only. */
11971221
suggestion_id?: string;
1222+
/** An array of multimedia attachments to be sent with the message.
1223+
*
1224+
* **Note:** Attachments are not processed by the assistant itself, but can be sent to external services by
1225+
* webhooks.
1226+
*/
1227+
attachments?: MessageInputAttachment[];
11981228
/** Optional properties that control how the assistant responds. */
11991229
options?: MessageInputOptionsStateless;
12001230
}
@@ -1223,15 +1253,15 @@ namespace AssistantV2 {
12231253

12241254
/** Additional detailed information about a message response and how it was generated. */
12251255
export interface MessageOutputDebug {
1226-
/** An array of objects containing detailed diagnostic information about the nodes that were triggered during
1256+
/** An array of objects containing detailed diagnostic information about dialog nodes that were triggered during
12271257
* processing of the input message.
12281258
*/
1229-
nodes_visited?: DialogNodesVisited[];
1259+
nodes_visited?: DialogNodeVisited[];
12301260
/** An array of up to 50 messages logged with the request. */
12311261
log_messages?: DialogLogMessage[];
12321262
/** Assistant sets this to true when this message response concludes or interrupts a dialog. */
12331263
branch_exited?: boolean;
1234-
/** When `branch_exited` is set to `true` by the Assistant, the `branch_exited_reason` specifies whether the
1264+
/** When `branch_exited` is set to `true` by the assistant, the `branch_exited_reason` specifies whether the
12351265
* dialog completed by itself or got interrupted.
12361266
*/
12371267
branch_exited_reason?: string;
@@ -1334,12 +1364,6 @@ namespace AssistantV2 {
13341364
value: string;
13351365
/** A decimal percentage that represents Watson's confidence in the recognized entity. */
13361366
confidence?: number;
1337-
/** **Deprecated.** Any metadata for the entity.
1338-
*
1339-
* Beginning with the `2021-06-14` API version, the `metadata` property is no longer returned. For information
1340-
* about system entities recognized in the user input, see the `interpretation` property.
1341-
*/
1342-
metadata?: JsonObject;
13431367
/** The recognized capture groups for the entity, as defined by the entity pattern. */
13441368
groups?: CaptureGroup[];
13451369
/** An object containing detailed information about the entity recognized in the user input. This property is
@@ -1590,6 +1614,30 @@ namespace AssistantV2 {
15901614
step: string;
15911615
}
15921616

1617+
/** RuntimeResponseGenericRuntimeResponseTypeAudio. */
1618+
export interface RuntimeResponseGenericRuntimeResponseTypeAudio extends RuntimeResponseGeneric {
1619+
/** The type of response returned by the dialog node. The specified response type must be supported by the
1620+
* client application or channel.
1621+
*/
1622+
response_type: string;
1623+
/** The `https:` URL of the audio clip. */
1624+
source: string;
1625+
/** The title or introductory text to show before the response. */
1626+
title?: string;
1627+
/** The description to show with the the response. */
1628+
description?: string;
1629+
/** An array of objects specifying channels for which the response is intended. If **channels** is present, the
1630+
* response is intended for a built-in integration and should not be handled by an API client.
1631+
*/
1632+
channels?: ResponseGenericChannel[];
1633+
/** For internal use only. */
1634+
channel_options?: JsonObject;
1635+
/** Descriptive text that can be used for screen readers or other situations where the audio player cannot be
1636+
* seen.
1637+
*/
1638+
alt_text?: string;
1639+
}
1640+
15931641
/** RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. */
15941642
export interface RuntimeResponseGenericRuntimeResponseTypeChannelTransfer extends RuntimeResponseGeneric {
15951643
/** The type of response returned by the dialog node. The specified response type must be supported by the
@@ -1634,6 +1682,26 @@ namespace AssistantV2 {
16341682
channels?: ResponseGenericChannel[];
16351683
}
16361684

1685+
/** RuntimeResponseGenericRuntimeResponseTypeIframe. */
1686+
export interface RuntimeResponseGenericRuntimeResponseTypeIframe extends RuntimeResponseGeneric {
1687+
/** The type of response returned by the dialog node. The specified response type must be supported by the
1688+
* client application or channel.
1689+
*/
1690+
response_type: string;
1691+
/** The `https:` URL of the embeddable content. */
1692+
source: string;
1693+
/** The title or introductory text to show before the response. */
1694+
title?: string;
1695+
/** The description to show with the the response. */
1696+
description?: string;
1697+
/** The URL of an image that shows a preview of the embedded content. */
1698+
image_url?: string;
1699+
/** An array of objects specifying channels for which the response is intended. If **channels** is present, the
1700+
* response is intended for a built-in integration and should not be handled by an API client.
1701+
*/
1702+
channels?: ResponseGenericChannel[];
1703+
}
1704+
16371705
/** RuntimeResponseGenericRuntimeResponseTypeImage. */
16381706
export interface RuntimeResponseGenericRuntimeResponseTypeImage extends RuntimeResponseGeneric {
16391707
/** The type of response returned by the dialog node. The specified response type must be supported by the
@@ -1753,6 +1821,28 @@ namespace AssistantV2 {
17531821
*/
17541822
channels?: ResponseGenericChannel[];
17551823
}
1824+
1825+
/** RuntimeResponseGenericRuntimeResponseTypeVideo. */
1826+
export interface RuntimeResponseGenericRuntimeResponseTypeVideo extends RuntimeResponseGeneric {
1827+
/** The type of response returned by the dialog node. The specified response type must be supported by the
1828+
* client application or channel.
1829+
*/
1830+
response_type: string;
1831+
/** The `https:` URL of the video. */
1832+
source: string;
1833+
/** The title or introductory text to show before the response. */
1834+
title?: string;
1835+
/** The description to show with the the response. */
1836+
description?: string;
1837+
/** An array of objects specifying channels for which the response is intended. If **channels** is present, the
1838+
* response is intended for a built-in integration and should not be handled by an API client.
1839+
*/
1840+
channels?: ResponseGenericChannel[];
1841+
/** For internal use only. */
1842+
channel_options?: JsonObject;
1843+
/** Descriptive text that can be used for screen readers or other situations where the video cannot be seen. */
1844+
alt_text?: string;
1845+
}
17561846
}
17571847

17581848
export = AssistantV2;

test/unit/assistant.v2.test.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2021.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -345,13 +345,18 @@ describe('AssistantV2', () => {
345345
location: [38],
346346
value: 'testString',
347347
confidence: 72.5,
348-
metadata: { 'key1': 'testString' },
349348
groups: [captureGroupModel],
350349
interpretation: runtimeEntityInterpretationModel,
351350
alternatives: [runtimeEntityAlternativeModel],
352351
role: runtimeEntityRoleModel,
353352
};
354353

354+
// MessageInputAttachment
355+
const messageInputAttachmentModel = {
356+
url: 'testString',
357+
media_type: 'testString',
358+
};
359+
355360
// MessageInputOptionsSpelling
356361
const messageInputOptionsSpellingModel = {
357362
suggestions: true,
@@ -375,6 +380,7 @@ describe('AssistantV2', () => {
375380
intents: [runtimeIntentModel],
376381
entities: [runtimeEntityModel],
377382
suggestion_id: 'testString',
383+
attachments: [messageInputAttachmentModel],
378384
options: messageInputOptionsModel,
379385
};
380386

@@ -387,6 +393,7 @@ describe('AssistantV2', () => {
387393
reference_time: 'testString',
388394
session_start_time: 'testString',
389395
state: 'testString',
396+
skip_user_input: true,
390397
};
391398

392399
// MessageContextGlobal
@@ -410,6 +417,7 @@ describe('AssistantV2', () => {
410417
const messageContextModel = {
411418
global: messageContextGlobalModel,
412419
skills: { 'key1': messageContextSkillModel },
420+
integrations: { foo: 'bar' },
413421
};
414422

415423
test('should pass the right params to createRequest', () => {
@@ -556,13 +564,18 @@ describe('AssistantV2', () => {
556564
location: [38],
557565
value: 'testString',
558566
confidence: 72.5,
559-
metadata: { 'key1': 'testString' },
560567
groups: [captureGroupModel],
561568
interpretation: runtimeEntityInterpretationModel,
562569
alternatives: [runtimeEntityAlternativeModel],
563570
role: runtimeEntityRoleModel,
564571
};
565572

573+
// MessageInputAttachment
574+
const messageInputAttachmentModel = {
575+
url: 'testString',
576+
media_type: 'testString',
577+
};
578+
566579
// MessageInputOptionsSpelling
567580
const messageInputOptionsSpellingModel = {
568581
suggestions: true,
@@ -584,6 +597,7 @@ describe('AssistantV2', () => {
584597
intents: [runtimeIntentModel],
585598
entities: [runtimeEntityModel],
586599
suggestion_id: 'testString',
600+
attachments: [messageInputAttachmentModel],
587601
options: messageInputOptionsStatelessModel,
588602
};
589603

@@ -596,6 +610,7 @@ describe('AssistantV2', () => {
596610
reference_time: 'testString',
597611
session_start_time: 'testString',
598612
state: 'testString',
613+
skip_user_input: true,
599614
};
600615

601616
// MessageContextGlobalStateless
@@ -620,6 +635,7 @@ describe('AssistantV2', () => {
620635
const messageContextStatelessModel = {
621636
global: messageContextGlobalStatelessModel,
622637
skills: { 'key1': messageContextSkillModel },
638+
integrations: { foo: 'bar' },
623639
};
624640

625641
test('should pass the right params to createRequest', () => {

0 commit comments

Comments
 (0)