Skip to content

Commit fdd4dd2

Browse files
feat(assistantv2): improved typing
1 parent 4fca678 commit fdd4dd2

File tree

2 files changed

+238
-28
lines changed

2 files changed

+238
-28
lines changed

assistant/v2.ts

Lines changed: 119 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ class AssistantV2 extends BaseService {
188188
}
189189

190190
const query = {
191+
'version': this.version,
191192
'page_limit': _params.pageLimit,
192193
'include_count': _params.includeCount,
193194
'sort': _params.sort,
@@ -1604,7 +1605,7 @@ class AssistantV2 extends BaseService {
16041605
* @param {JsonObject} [params.workspace] - An object containing the conversational content of an action or dialog
16051606
* skill.
16061607
* @param {JsonObject} [params.dialogSettings] - For internal use only.
1607-
* @param {JsonObject} [params.searchSettings] - A JSON object describing the search skill configuration.
1608+
* @param {SearchSettings} [params.searchSettings] - An object describing the search skill configuration.
16081609
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
16091610
* @returns {Promise<AssistantV2.Response<AssistantV2.Skill>>}
16101611
*/
@@ -2441,8 +2442,8 @@ namespace AssistantV2 {
24412442
workspace?: JsonObject;
24422443
/** For internal use only. */
24432444
dialogSettings?: JsonObject;
2444-
/** A JSON object describing the search skill configuration. */
2445-
searchSettings?: JsonObject;
2445+
/** An object describing the search skill configuration. */
2446+
searchSettings?: SearchSettings;
24462447
headers?: OutgoingHttpHeaders;
24472448
}
24482449

@@ -2841,8 +2842,8 @@ namespace AssistantV2 {
28412842
export interface MessageContext {
28422843
/** Session context data that is shared by all skills used by the assistant. */
28432844
global?: MessageContextGlobal;
2844-
/** Information specific to particular skills used by the assistant. */
2845-
skills?: JsonObject;
2845+
/** Context data specific to particular skills used by the assistant. */
2846+
skills?: MessageContextSkills;
28462847
/** An object containing context data that is specific to particular integrations. For more information, see the
28472848
* [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations).
28482849
*/
@@ -2921,9 +2922,25 @@ namespace AssistantV2 {
29212922
skip_user_input?: boolean;
29222923
}
29232924

2924-
/** Contains information specific to a particular skill used by the assistant. The property name must be the same as the name of the skill. **Note:** The default skill names are `main skill` for the dialog skill (if enabled) and `actions skill` for the action skill. */
2925-
export interface MessageContextSkill {
2926-
/** Arbitrary variables that can be read and written by a particular skill. */
2925+
/** Context variables that are used by the action skill. */
2926+
export interface MessageContextSkillAction {
2927+
/** An object containing any arbitrary variables that can be read and written by a particular skill. */
2928+
user_defined?: JsonObject;
2929+
/** System context data used by the skill. */
2930+
system?: MessageContextSkillSystem;
2931+
/** An object containing action variables. Action variables can be accessed only by steps in the same action,
2932+
* and do not persist after the action ends.
2933+
*/
2934+
action_variables?: JsonObject;
2935+
/** An object containing skill variables. (In the Watson Assistant user interface, skill variables are called
2936+
* _session variables_.) Skill variables can be accessed by any action and persist for the duration of the session.
2937+
*/
2938+
skill_variables?: JsonObject;
2939+
}
2940+
2941+
/** Context variables that are used by the dialog skill. */
2942+
export interface MessageContextSkillDialog {
2943+
/** An object containing any arbitrary variables that can be read and written by a particular skill. */
29272944
user_defined?: JsonObject;
29282945
/** System context data used by the skill. */
29292946
system?: MessageContextSkillSystem;
@@ -2941,12 +2958,20 @@ namespace AssistantV2 {
29412958
[propName: string]: any;
29422959
}
29432960

2961+
/** Context data specific to particular skills used by the assistant. */
2962+
export interface MessageContextSkills {
2963+
/** Context variables that are used by the dialog skill. */
2964+
'main skill'?: MessageContextSkillDialog;
2965+
/** Context variables that are used by the action skill. */
2966+
'actions skill'?: MessageContextSkillAction;
2967+
}
2968+
29442969
/** MessageContextStateless. */
29452970
export interface MessageContextStateless {
29462971
/** Session context data that is shared by all skills used by the assistant. */
29472972
global?: MessageContextGlobalStateless;
2948-
/** Information specific to particular skills used by the assistant. */
2949-
skills?: JsonObject;
2973+
/** Context data specific to particular skills used by the assistant. */
2974+
skills?: MessageContextSkills;
29502975
/** An object containing context data that is specific to particular integrations. For more information, see the
29512976
* [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations).
29522977
*/
@@ -3501,8 +3526,7 @@ namespace AssistantV2 {
35013526
* query. Currently, only the single answer with the highest confidence (if any) is returned.
35023527
*
35033528
* **Notes:**
3504-
* - This property uses the answer finding beta feature, and is available only if the search skill is connected to
3505-
* a Discovery v2 service instance.
3529+
* - Answer finding is available only if the search skill is connected to a Discovery v2 service instance.
35063530
* - Answer finding is not supported on IBM Cloud Pak for Data.
35073531
*/
35083532
answers?: SearchResultAnswer[];
@@ -3544,6 +3568,80 @@ namespace AssistantV2 {
35443568
score?: number;
35453569
}
35463570

3571+
/** An object describing the search skill configuration. */
3572+
export interface SearchSettings {
3573+
/** Configuration settings for the Watson Discovery service instance used by the search integration. */
3574+
discovery: SearchSettingsDiscovery;
3575+
/** The messages included with responses from the search integration. */
3576+
messages: SearchSettingsMessages;
3577+
/** The mapping between fields in the Watson Discovery collection and properties in the search response. */
3578+
schema_mapping: SearchSettingsSchemaMapping;
3579+
}
3580+
3581+
/** Configuration settings for the Watson Discovery service instance used by the search integration. */
3582+
export interface SearchSettingsDiscovery {
3583+
/** The ID for the Watson Discovery service instance. */
3584+
instance_id: string;
3585+
/** The ID for the Watson Discovery project. */
3586+
project_id: string;
3587+
/** The URL for the Watson Discovery service instance. */
3588+
url: string;
3589+
/** The maximum number of primary results to include in the response. */
3590+
max_primary_results?: number;
3591+
/** The maximum total number of primary and additional results to include in the response. */
3592+
max_total_results?: number;
3593+
/** The minimum confidence threshold for included results. Any results with a confidence below this threshold
3594+
* will be discarded.
3595+
*/
3596+
confidence_threshold?: number;
3597+
/** Whether to include the most relevant passages of text in the **highlight** property of each result. */
3598+
highlight?: boolean;
3599+
/** Whether to use the answer finding feature to emphasize answers within highlighted passages. This property is
3600+
* ignored if **highlight**=`false`.
3601+
*
3602+
* **Notes:**
3603+
* - Answer finding is available only if the search skill is connected to a Discovery v2 service instance.
3604+
* - Answer finding is not supported on IBM Cloud Pak for Data.
3605+
*/
3606+
find_answers?: boolean;
3607+
/** Authentication information for the Watson Discovery service. For more information, see the [Watson Discovery
3608+
* documentation](https://cloud.ibm.com/apidocs/discovery-data#authentication).
3609+
*
3610+
* **Note:** You must specify either **basic** or **bearer**, but not both.
3611+
*/
3612+
authentication: SearchSettingsDiscoveryAuthentication;
3613+
}
3614+
3615+
/** Authentication information for the Watson Discovery service. For more information, see the [Watson Discovery documentation](https://cloud.ibm.com/apidocs/discovery-data#authentication). **Note:** You must specify either **basic** or **bearer**, but not both. */
3616+
export interface SearchSettingsDiscoveryAuthentication {
3617+
/** The HTTP basic authentication credentials for Watson Discovery. Specify your Watson Discovery API key in the
3618+
* format `apikey:{apikey}`.
3619+
*/
3620+
basic?: string;
3621+
/** The authentication bearer token for Watson Discovery. */
3622+
bearer?: string;
3623+
}
3624+
3625+
/** The messages included with responses from the search integration. */
3626+
export interface SearchSettingsMessages {
3627+
/** The message to include in the response to a successful query. */
3628+
success: string;
3629+
/** The message to include in the response when the query encounters an error. */
3630+
error: string;
3631+
/** The message to include in the response when there is no result from the query. */
3632+
no_result: string;
3633+
}
3634+
3635+
/** The mapping between fields in the Watson Discovery collection and properties in the search response. */
3636+
export interface SearchSettingsSchemaMapping {
3637+
/** The field in the collection to map to the **url** property of the response. */
3638+
url: string;
3639+
/** The field in the collection to map to the **body** property in the response. */
3640+
body: string;
3641+
/** The field in the collection to map to the **title** property for the schema. */
3642+
title: string;
3643+
}
3644+
35473645
/** A warning describing an error in the search skill configuration. */
35483646
export interface SearchSkillWarning {
35493647
/** The error code. */
@@ -3603,8 +3701,8 @@ namespace AssistantV2 {
36033701
* versionable skill is saved for each new release of an assistant.
36043702
*/
36053703
next_snapshot_version?: string;
3606-
/** A JSON object describing the search skill configuration. */
3607-
search_settings?: JsonObject;
3704+
/** An object describing the search skill configuration. */
3705+
search_settings?: SearchSettings;
36083706
/** An array of warnings describing errors with the search skill configuration. Included only for search skills. */
36093707
warnings?: SearchSkillWarning[];
36103708
/** The language of the skill. */
@@ -3656,8 +3754,8 @@ namespace AssistantV2 {
36563754
* versionable skill is saved for each new release of an assistant.
36573755
*/
36583756
next_snapshot_version?: string;
3659-
/** A JSON object describing the search skill configuration. */
3660-
search_settings?: JsonObject;
3757+
/** An object describing the search skill configuration. */
3758+
search_settings?: SearchSettings;
36613759
/** An array of warnings describing errors with the search skill configuration. Included only for search skills. */
36623760
warnings?: SearchSkillWarning[];
36633761
/** The language of the skill. */
@@ -3671,10 +3769,11 @@ namespace AssistantV2 {
36713769
/** The assistant ID of the assistant. */
36723770
assistant_id?: string;
36733771
/** The current status of the asynchronous operation:
3674-
* - **Available**: The export is available.
3675-
* - **Failed**: An asynchronous export operation has failed. See the **status_errors** property for more
3676-
* information about the cause of the failure.
3677-
* - **Processing**: An asynchronous export operation has not yet completed.
3772+
* - `Available`: An asynchronous export is available.
3773+
* - `Completed`: An asynchronous import operation has completed successfully.
3774+
* - `Failed`: An asynchronous operation has failed. See the **status_errors** property for more information about
3775+
* the cause of the failure.
3776+
* - `Processing`: An asynchronous operation has not yet completed.
36783777
*/
36793778
status?: string;
36803779
/** The description of the failed asynchronous operation. Included only if **status**=`Failed`. */

0 commit comments

Comments
 (0)