@ibm-cloud/watsonx-ai
Version:
IBM watsonx.ai Node.js SDK
1,159 lines • 230 kB
TypeScript
/**
* (C) Copyright IBM Corp. 2025-2026.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/// <reference types="node" />
import type { UserOptions } from 'ibm-cloud-sdk-core';
import type { BaseServiceOptions } from 'ibm-cloud-sdk-core/es/lib/base-service.js';
import type * as Messages from "./messages.js";
import type { TextChatMessages, TextChatMessageSystem, TextChatMessageTool, TextChatMessageUser, TextChatToolCall, TextChatUserImageURLContent, TextChatUserTextContent } from "./messages.js";
import type { EncryptionParams } from "./encryption.js";
import type { JsonObject, DefaultParams } from "./common.js";
import type { ReadStream } from 'fs';
/** Options for the `WatsonXAI` constructor. */
export interface Options extends UserOptions {
/**
* The version date for the API of the form `YYYY-MM-DD`. If not provided, the version date will
* be automatically determined from the VERSION.ts file modification date.
*/
version?: string;
}
/** Request interfaces */
/** Parameters for the `createDeployment` operation. */
export interface CreateDeploymentParams extends DefaultParams {
/** The name of the resource. */
name: string;
/**
* Indicates that this is an online deployment. An object has to be specified but can be empty.
* The `serving_name` can be provided in the `online.parameters`.
*/
online: OnlineDeployment;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** A description of the resource. */
description?: string;
/** A list of tags for this resource. */
tags?: string[];
/** User defined properties specified as key-value pairs. */
custom?: JsonObject;
/** A reference to a resource. */
promptTemplate?: SimpleRel;
/** A hardware specification. */
hardwareSpec?: HardwareSpec;
/** The requested hardware for deployment. */
hardwareRequest?: HardwareRequest;
/** A reference to a resource. */
asset?: Rel;
/**
* The base model that is required for this deployment if this is for a prompt template or a
* prompt tune for an IBM foundation model.
*/
baseModelId?: string;
/**
* The base deployment when this is a custom foundation model with a prompt template. The id must
* be the id of the custom foundation model deployment.
*/
baseDeploymentId?: string;
}
/** Parameters for the `listDeployments` operation. */
export interface ListDeploymentsParams extends DefaultParams {
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
/** Retrieves the deployment, if any, that contains this `serving_name`. */
servingName?: string;
/** Retrieves only the resources with the given tag value. */
tagValue?: string;
/** Retrieves only the resources with the given asset_id, asset_id would be the model id. */
assetId?: string;
/** Retrieves only the resources with the given prompt_template_id. */
promptTemplateId?: string;
/** Retrieves only the resources with the given name. */
name?: string;
/**
* Retrieves the resources filtered with the given type. There are the deployment types as well as
* an additional `prompt_template` if the deployment type includes a prompt template.
*
* The supported deployment types are (see the description for `deployed_asset_type` in the
* deployment entity):
*
* 1. `prompt_tune` - when a prompt tuned model is deployed. 2. `foundation_model` - when a prompt
* template is used on a pre-deployed IBM provided model. 3. `custom_foundation_model`
*
* - When a custom foundation model is deployed.
*
* These can be combined with the flag `prompt_template` like this:
*
* 1. `type=prompt_tune` - return all prompt tuned model deployments. 2. `type=prompt_tune and
* prompt_template` - return all prompt tuned model deployments with a prompt template. 3.
* `type=foundation_model` - return all prompt template deployments. 4. `type=foundation_model
* and prompt_template` - return all prompt template deployments
*
* - This is the same as the previous query because a `foundation_model` can only exist with a
* prompt template.
*
* 5. `type=prompt_template` - return all deployments with a prompt template.
*/
type?: string;
/**
* Retrieves the resources filtered by state. Allowed values are `initializing`, `updating`,
* `ready` and `failed`.
*/
state?: string;
/**
* Returns whether `serving_name` is available for use or not. This query parameter cannot be
* combined with any other parameter except for `serving_name`.
*/
conflict?: boolean;
}
/** Parameters for the `deploymentsGet` operation. */
export interface DeploymentsGetParams extends DefaultParams {
/** The deployment id. */
deploymentId: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Parameters for the `deploymentsUpdate` operation. */
export interface DeploymentsUpdateParams extends DefaultParams {
/** The deployment id. */
deploymentId: string;
/** The json patch. */
jsonPatch: JsonPatchOperation[];
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Parameters for the `deploymentsDelete` operation. */
export interface DeploymentsDeleteParams extends DefaultParams {
/** The deployment id. */
deploymentId: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Parameters for the `deploymentsTextGeneration` operation. */
export interface DeploymentsTextGenerationParams extends DefaultParams {
/**
* The `id_or_name` can be either the `deployment_id` that identifies the deployment or a
* `serving_name` that allows a predefined URL to be used to post a prediction.
*
* The `project` or `space` for the deployment must have a WML instance that will be used for
* limits and billing (if a paid plan).
*/
idOrName: string;
/**
* The prompt to generate completions. Note: The method tokenizes the input internally. It is
* recommended not to leave any trailing spaces.
*
* This field is ignored if there is a prompt template.
*/
input?: string;
/** The template properties if this request refers to a prompt template. */
parameters?: DeploymentTextGenProperties;
/**
* Properties that control the moderations, for usages such as `Hate and profanity` (HAP) and
* `Personal identifiable information` (PII) filtering. This list can be extended with new types
* of moderations.
*/
moderations?: Moderations;
}
/** Parameters for the `deploymentsTextGenerationStream` operation. */
export interface DeploymentsTextGenerationStreamParams extends DefaultParams {
/**
* The `id_or_name` can be either the `deployment_id` that identifies the deployment or a
* `serving_name` that allows a predefined URL to be used to post a prediction.
*
* The `project` or `space` for the deployment must have a WML instance that will be used for
* limits and billing (if a paid plan).
*/
idOrName: string;
/**
* The prompt to generate completions. Note: The method tokenizes the input internally. It is
* recommended not to leave any trailing spaces.
*
* This field is ignored if there is a prompt template.
*/
input?: string;
/** The template properties if this request refers to a prompt template. */
parameters?: DeploymentTextGenProperties;
/**
* Properties that control the moderations, for usages such as `Hate and profanity` (HAP) and
* `Personal identifiable information` (PII) filtering. This list can be extended with new types
* of moderations.
*/
moderations?: Moderations;
returnObject?: boolean;
}
/** Parameters for the `deploymentsTextChat` operation. */
export interface DeploymentsTextChatParams extends TextChatParameters, DefaultParams {
/**
* The `id_or_name` can be either the `deployment_id` that identifies the deployment or a
* `serving_name` that allows a predefined URL to be used to post a prediction. The deployment
* must reference a prompt template with `input_mode` `chat`.
*
* The WML instance that is associated with the deployment will be used for limits and billing (if
* a paid plan).
*/
idOrName: string;
/**
* The messages for this chat session. You cannot specify `system` `role` in the messages.
* Depending on the model, the `content` of `system` `role` may be from `system_prompt` of the
* prompt template, and will be automatically inserted into `messages`.
*
* As an example, depending on the model, if `system_prompt` of a prompt template is "You are
* Granite Chat, an AI language model developed by IBM. You are a cautious assistant. You
* carefully follow instructions. You are helpful and harmless and you follow ethical guidelines
* and promote positive behavior.", a message with `system` `role` having `content` the same as
* `system_prompt` is inserted.
*/
messages: DeploymentTextChatMessages[];
/**
* If specified, `context` will be inserted into `messages`. Depending on the model, `context` may
* be inserted into the `content` with `system` `role`; or into the `content` of the last message
* of `user` `role`.
*
* In the example, `context` "Today is Wednesday" is inserted as such `content` of `user` becomes
* "Today is Wednesday. Who are you and which day is tomorrow?".
*/
context?: string;
}
/** Parameters for the `deploymentsTextChatStream` operation. */
export interface DeploymentsTextChatStreamParams extends DeploymentsTextChatParams {
returnObject?: boolean;
}
/** Parameters for the `deploymentsTimeSeriesForecast` operation. */
export interface DeploymentsTimeSeriesForecastParams extends DefaultParams {
/**
* The `id_or_name` can be either the `deployment_id` that identifies the deployment or a
* `serving_name` that allows a predefined URL to be used to post a prediction.
*
* The WML instance that is associated with the deployment will be used for limits and billing (if
* a paid plan).
*/
idOrName: string;
/**
* A payload of data matching `schema`. We assume the following about your data:
*
* - All timeseries are of equal length and are uniform in nature (the time difference between two
* successive rows is constant). This implies that there are no missing rows of data;
* - The data meet the minimum model-dependent historical context length which can be any number of
* rows per timeseries;
*
* Note that the example payloads shown are for illustration purposes only. An actual payload
* would necessary be much larger to meet minimum model-specific context lengths.
*/
data: JsonObject;
/** Contains metadata about your timeseries data input. */
schema: TSForecastInputSchema;
/** The parameters for the forecast request. */
parameters?: DeploymentTSForecastParameters;
/**
* Exogenous or supporting features that extend into the forecasting horizon (e.g., a weather
* forecast or calendar of special promotions) which are known in advance. `future_data` would be
* in the same format as `data` except that all timestamps would be in the forecast horizon and it
* would not include previously specified `target_columns`.
*/
futureData?: JsonObject;
}
/** Parameters for the `listFoundationModelSpecs` operation. */
export interface ListFoundationModelSpecsParams extends DefaultParams {
/**
* Token required for token-based pagination. This token cannot be determined by end user. It is
* generated by the service and it is set in the href available in the `next` field.
*/
start?: string;
/** How many resources should be returned. By default limit is 100. Max limit allowed is 200. */
limit?: number;
/**
* A set of filters to specify the list of models, filters are described as the `pattern` shown
* below.
*
* ```text
* pattern: tfilter[,tfilter][:(or|and)]
* tfilter: filter | !filter
* filter: Requires existence of the filter.
* !filter: Requires absence of the filter.
* filter: one of
* modelid_*: Filters by model id.
* Namely, select a model with a specific model id.
* provider_*: Filters by provider.
* Namely, select all models with a specific provider.
* source_*: Filters by source.
* Namely, select all models with a specific source.
* input_tier_*: Filters by input tier.
* Namely, select all models with a specific input tier.
* output_tier_*: Filters by output tier.
* Namely, select all models with a specific output tier.
* tier_*: Filters by tier.
* Namely, select all models with a specific input or output tier.
* task_*: Filters by task id.
* Namely, select all models that support a specific task id.
* lifecycle_*: Filters by lifecycle state.
* Namely, select all models that are currently in the specified lifecycle state.
* function_*: Filters by function.
* Namely, select all models that support a specific function.
* ```.
* ```
*/
filters?: string;
/** See all the `Tech Preview` models if entitled. */
techPreview?: boolean;
}
/** Parameters for the `listFoundationModelTasks` operation. */
export interface ListFoundationModelTasksParams extends DefaultParams {
/**
* Token required for token-based pagination. This token cannot be determined by end user. It is
* generated by the service and it is set in the href available in the `next` field.
*/
start?: string;
/** How many resources should be returned. By default limit is 100. Max limit allowed is 200. */
limit?: number;
}
/** Parameters for the `postPrompt` operation. */
export interface PostPromptParams extends DefaultParams {
/** Name used to display the prompt. */
name: string;
prompt: PromptWithExternal;
/** An optional description for the prompt. */
description?: string;
/** Time the prompt was created. */
createdAt?: number;
taskIds?: string[];
lock?: PromptLock;
modelVersion?: WxPromptPostModelVersion;
promptVariables?: JsonObject;
/** Input mode in use for the prompt. */
inputMode?: PostPromptConstants.InputMode | string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
}
/** Constants for the `postPrompt` operation. */
export declare namespace PostPromptConstants {
/** Input mode in use for the prompt. */
enum InputMode {
STRUCTURED = "structured",
FREEFORM = "freeform",
CHAT = "chat",
DETACHED = "detached"
}
}
/** Parameters for the `getPrompt` operation. */
export interface GetPromptParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
/** Only return a set of model parameters compatiable with inferencing. */
restrictModelParameters?: string;
}
export interface CatalogSearch {
/**
* The limit request body field can be specified to limit the number of assets in the search
* results. The default limit is 200. The maximum limit value is 200, and any greater value is
* ignored.
*/
limit?: number;
/** Returns the number of query results for each unique value of each named field. */
counts?: string[];
/**
* Restrict results to documents with a dimension equal to the specified label. Note that,
* multiple values for a single key in a drilldown means an OR relation between them and there is
* an AND relation between multiple keys.
*/
drilldown?: Record<string, any>;
/** Bookmark of the query result */
bookmark?: string;
/** Sort order for the query */
sort?: string;
/** Entity */
include?: string;
}
export interface PromptListParams extends DefaultParams, CatalogSearch {
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
}
/** Parameters for the `patchPrompt` operation. */
export interface PatchPromptParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/** Name used to display the prompt. */
name: string;
prompt: Prompt;
/** The prompt's id. This value cannot be set. It is returned in responses only. */
id?: string;
/** An optional description for the prompt. */
description?: string;
taskIds?: string[];
governanceTracked?: boolean;
modelVersion?: WxPromptPatchModelVersion;
promptVariables?: JsonObject;
/** Input mode in use for the prompt. */
inputMode?: PatchPromptConstants.InputMode | string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
}
/** Constants for the `patchPrompt` operation. */
export declare namespace PatchPromptConstants {
/** Input mode in use for the prompt. */
enum InputMode {
STRUCTURED = "structured",
FREEFORM = "freeform"
}
}
/** Parameters for the `deletePrompt` operation. */
export interface DeletePromptParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
}
/** Parameters for the `putPromptLock` operation. */
export interface PutPromptLockParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/** True if the prompt is currently locked. */
locked: boolean;
/**
* Lock type: 'edit' for working on prompts/templates or 'governance'. Can only be supplied in PUT
* /lock requests.
*/
lockType?: PutPromptLockConstants.LockType | string;
/** Locked by is computed by the server and shouldn't be passed. */
lockedBy?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
/** Override a lock if it is currently taken. */
force?: boolean;
}
/** Constants for the `putPromptLock` operation. */
export declare namespace PutPromptLockConstants {
/**
* Lock type: 'edit' for working on prompts/templates or 'governance'. Can only be supplied in PUT
* /lock requests.
*/
enum LockType {
EDIT = "edit",
GOVERNANCE = "governance"
}
}
/** Parameters for the `getPromptLock` operation. */
export interface GetPromptLockParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `getPromptInput` operation. */
export interface GetPromptInputParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
/**
* Override input string that will be used to generate the response. The string can contain
* template parameters.
*/
input?: string;
/**
* Supply only to replace placeholders. Object content must be key:value pairs where the 'key' is
* the parameter to replace and 'value' is the value to use.
*/
promptVariables?: JsonObject;
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `postPromptChatItem` operation. */
export interface PostPromptChatItemParams extends DefaultParams {
/** Prompt ID. */
promptId: string;
chatItem: ChatItem[];
/** [REQUIRED] Specifies the space ID as the target. One target must be supplied per request. */
spaceId?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `postPromptSession` operation. */
export interface PostPromptSessionParams extends DefaultParams {
/** Name used to display the prompt session. */
name: string;
/** The prompt session's id. This value cannot be set. It is returned in responses only. */
id?: string;
/** An optional description for the prompt session. */
description?: string;
/** Time the session was created. */
createdAt?: number;
/** The ID of the original session creator. */
createdBy?: string;
/** Time the session was updated. */
lastUpdatedAt?: number;
/** The ID of the last user that modifed the session. */
lastUpdatedBy?: string;
lock?: PromptLock;
prompts?: WxPromptSessionEntry[];
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `getPromptSession` operation. */
export interface GetPromptSessionParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** Include the most recent entry. */
prefetch?: boolean;
}
/** Parameters for the `patchPromptSession` operation. */
export interface PatchPromptSessionParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
name?: string;
/** An optional description for the prompt. */
description?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `deletePromptSession` operation. */
export interface DeletePromptSessionParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `postPromptSessionEntry` operation. */
export interface PostPromptSessionEntryParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** Name used to display the prompt. */
name: string;
/** Time the prompt was created. */
createdAt: number;
prompt: Prompt;
/** The prompt's id. This value cannot be set. It is returned in responses only. */
id?: string;
/** An optional description for the prompt. */
description?: string;
promptVariables?: JsonObject;
isTemplate?: boolean;
/** Input mode in use for the prompt. */
inputMode?: PostPromptSessionEntryConstants.InputMode | string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Constants for the `postPromptSessionEntry` operation. */
export declare namespace PostPromptSessionEntryConstants {
/** Input mode in use for the prompt. */
enum InputMode {
STRUCTURED = "structured",
FREEFORM = "freeform",
CHAT = "chat"
}
}
/** Parameters for the `getPromptSessionEntries` operation. */
export interface GetPromptSessionEntriesParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** Bookmark from a previously limited get request. */
bookmark?: string;
/** Limit for results to retrieve, default 20. */
limit?: string;
}
/** Parameters for the `postPromptSessionEntryChatItem` operation. */
export interface PostPromptSessionEntryChatItemParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** Prompt Session Entry ID. */
entryId: string;
chatItem: ChatItem[];
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `putPromptSessionLock` operation. */
export interface PutPromptSessionLockParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** True if the prompt is currently locked. */
locked: boolean;
/**
* Lock type: 'edit' for working on prompts/templates or 'governance'. Can only be supplied in PUT
* /lock requests.
*/
lockType?: PutPromptSessionLockConstants.LockType | string;
/** Locked by is computed by the server and shouldn't be passed. */
lockedBy?: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
/** Override a lock if it is currently taken. */
force?: boolean;
}
/** Constants for the `putPromptSessionLock` operation. */
export declare namespace PutPromptSessionLockConstants {
/**
* Lock type: 'edit' for working on prompts/templates or 'governance'. Can only be supplied in PUT
* /lock requests.
*/
enum LockType {
EDIT = "edit",
GOVERNANCE = "governance"
}
}
/** Parameters for the `getPromptSessionLock` operation. */
export interface GetPromptSessionLockParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `getPromptSessionEntry` operation. */
export interface GetPromptSessionEntryParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** Prompt Session Entry ID. */
entryId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Parameters for the `deletePromptSessionEntry` operation. */
export interface DeletePromptSessionEntryParams extends DefaultParams {
/** Prompt Session ID. */
sessionId: string;
/** Prompt Session Entry ID. */
entryId: string;
/** [REQUIRED] Specifies the project ID as the target. One target must be supplied per request. */
projectId?: string;
}
/** Constants for the `textChat` operation. */
export declare namespace TextChatConstants {
/**
* Using `none` means the model will not call any tool and instead generates a message. **The
* following options (`auto` and `required`) are not yet supported.** Using `auto` means the model
* can pick between generating a message or calling one or more tools. Using `required` means the
* model must call one or more tools. Only one of `tool_choice_option` or `tool_choice` must be
* present.
*/
enum ToolChoiceOption {
NONE = "none",
AUTO = "auto",
REQUIRED = "required"
}
}
interface TextChatParameters {
tools?: TextChatParameterTools[];
/**
* Using `none` means the model will not call any tool and instead generates a message.
*
* **The following options (`auto` and `required`) are not yet supported.**
*
* Using `auto` means the model can pick between generating a message or calling one or more
* tools. Using `required` means the model must call one or more tools.
*
* Only one of `tool_choice_option` or `tool_choice` must be present.
*/
toolChoiceOption?: TextChatConstants.ToolChoiceOption | string;
/**
* Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}`
* forces the model to call that tool.
*
* Only one of `tool_choice_option` or `tool_choice` must be present.
*/
toolChoice?: TextChatToolChoiceTool;
/**
* Positive values penalize new tokens based on their existing frequency in the text so far,
* decreasing the model's likelihood to repeat the same line verbatim.
*/
frequencyPenalty?: number;
/**
* Increasing or decreasing probability of tokens being selected during generation; a positive
* bias makes a token more likely to appear, while a negative bias makes it less likely.
*/
logitBias?: JsonObject;
/**
* Whether to return log probabilities of the output tokens or not. If true, returns the log
* probabilities of each output token returned in the content of message.
*/
logprobs?: boolean;
/**
* An integer specifying the number of most likely tokens to return at each token position, each
* with an associated log probability. The option `logprobs` must be set to `true` if this
* parameter is used.
*/
topLogprobs?: number;
/**
* The maximum number of tokens that can be generated in the chat completion. The total length of
* input tokens and generated tokens is limited by the model's context length. Set to 0 for the
* model's configured max generated tokens. This value is now deprecated in favor of
* maxCompletionTokens. If specified together with maxCompletionTokens, maxTokens will be
* ignored.
*/
maxTokens?: number;
/**
* The maximum number of tokens that can be generated in the chat completion. The total length of
* input tokens and generated tokens is limited by the model's context length. Set to 0 for the
* model's configured max generated tokens.
*/
maxCompletionTokens?: number;
/**
* How many chat completion choices to generate for each input message. Note that you will be
* charged based on the number of generated tokens across all of the choices. Keep n as 1 to
* minimize costs.
*/
n?: number;
/**
* Positive values penalize new tokens based on whether they appear in the text so far, increasing
* the model's likelihood to talk about new topics.
*/
presencePenalty?: number;
/** The chat response format parameters. */
responseFormat?: TextChatResponseFormat;
/** Random number generator seed to use in sampling mode for experimental repeatability. */
seed?: number;
/**
* Stop sequences are one or more strings which will cause the text generation to stop if/when
* they are produced as part of the output. Stop sequences encountered prior to the minimum number
* of tokens being generated will be ignored.
*/
stop?: string[];
/**
* What sampling temperature to use,. Higher values like 0.8 will make the output more random,
* while lower values like 0.2 will make it more focused and deterministic.
*
* We generally recommend altering this or `top_p` but not both.
*/
temperature?: number;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model considers
* the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising
* the top 10% probability mass are considered.
*
* We generally recommend altering this or `temperature` but not both.
*/
topP?: number;
/**
* Time limit in milliseconds - if not completed within this time, generation will stop. The text
* generated so far will be returned along with the `TIME_LIMIT`` stop reason. Depending on the
* users plan, and on the model being used, there may be an enforced maximum time limit.
*/
timeLimit?: number;
/**
* Represents the penalty for penalizing tokens that have already been generated or belong to the
* context.
*/
repetitionPenalty?: number;
/**
* Exponential penalty to the length that is used with beam-based generation. It is applied as an
* exponent to the sequence length, which in turn is used to divide the score of the sequence.
* Since the score is the log likelihood of the sequence (i.e. negative), `lengthPenalty` > 0.0
* promotes longer sequences, while `lengthPenalty` < 0.0 encourages shorter sequences.
*/
lengthPenalty?: number;
/** Whether to include reasoning_content in the response. Default is true. */
includeReasoning?: boolean;
/**
* A lower reasoning effort can result in faster responses, fewer tokens used, and shorter
* reasoning_content in the responses. Supported values are low, medium, and high.
*/
reasoningEffort?: 'low' | 'medium' | 'high';
}
/** Parameters for the `textChat` operation. */
export interface TextChatParams extends TextChatParameters, DefaultParams, EncryptionParams {
/**
* The model to use for the chat completion.
*
* Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx).
*/
modelId: string;
/** The messages for this chat session. */
messages: TextChatMessages[];
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** If specified, the output will be exactly one of the choices. */
guidedChoice?: string[];
/** If specified, the output will follow the regex pattern. */
guidedRegex?: string;
/** If specified, the output will follow the context free grammar. */
guidedGrammar?: string;
/**
* If specified, the output will follow the JSON schema. See the JSON Schema reference for
* documentation about the format.
*/
guidedJSON?: string;
}
/** Parameters for the `textChatStream` operation. */
export interface TextChatStreamParams extends TextChatParams {
returnObject?: boolean;
crypto?: undefined;
}
/** Constants for the `textChatStream` operation. */
export declare namespace TextChatStreamConstants {
/**
* Using `none` means the model will not call any tool and instead generates a message. **The
* following options (`auto` and `required`) are not yet supported.** Using `auto` means the model
* can pick between generating a message or calling one or more tools. Using `required` means the
* model must call one or more tools. Only one of `tool_choice_option` or `tool_choice` must be
* present.
*/
enum ToolChoiceOption {
NONE = "none",
AUTO = "auto",
REQUIRED = "required"
}
}
/** Parameters for the `textEmbeddings` operation. */
export interface TextEmbeddingsParams extends DefaultParams, EncryptionParams {
/**
* The `id` of the model to be used for this request. Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models-embed.html?context=wx&audience=wdp).
*/
modelId: string;
/** The input text. */
inputs: string[];
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** Parameters for text embedding requests. */
parameters?: EmbeddingParameters;
}
/** Parameters for the `textExtraction` operation. */
export interface TextExtractionParams extends DefaultParams {
/** A reference to data. */
documentReference: TextExtractionDataReference;
/** A reference to data. */
resultsReference: TextExtractionDataReference;
/** The steps for the text extraction pipeline. */
steps?: TextExtractionSteps;
/**
* Set this as an empty object to specify `json` output.
*
* Note that this is not strictly required because if an `assembly_md` object is not found then
* the default will be `json`.
*/
assemblyJson?: JsonObject;
/** Set this as an empty object to specify `markdown` output. */
assemblyMd?: JsonObject;
/** User defined properties specified as key-value pairs. */
custom?: JsonObject;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
}
/** Parameters for the `listTextExtractions` operation. */
export interface ListTextExtractionsParams extends DefaultParams {
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
/**
* Token required for token-based pagination. This token cannot be determined by end user. It is
* generated by the service and it is set in the href available in the `next` field.
*/
start?: string;
/** How many resources should be returned. By default limit is 100. Max limit allowed is 200. */
limit?: number;
}
/** Parameters for the `textExtractionGet` operation. */
export interface TextExtractionGetParams extends DefaultParams {
/** The identifier of the extraction request. */
id: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Parameters for the `textExtractionDelete` operation. */
export interface TextExtractionDeleteParams extends DefaultParams {
/** The identifier of the extraction request. */
id: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
/** Set to true in order to also delete the job or request metadata. */
hardDelete?: boolean;
}
/** Parameters for the `textGeneration` operation. */
export interface TextGenerationParams extends DefaultParams, EncryptionParams {
/**
* The prompt to generate completions. Note: The method tokenizes the input internally. It is
* recommended not to leave any trailing spaces.
*/
input: string;
/**
* The `id` of the model to be used for this request. Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx).
*/
modelId: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** Properties that control the model and response. */
parameters?: TextGenParameters;
/**
* Properties that control the moderations, for usages such as `Hate and profanity` (HAP) and
* `Personal identifiable information` (PII) filtering. This list can be extended with new types
* of moderations.
*/
moderations?: Moderations;
}
/** Parameters for the `textGenerationStream` operation. */
export interface TextGenerationStreamParams extends DefaultParams {
/**
* The prompt to generate completions. Note: The method tokenizes the input internally. It is
* recommended not to leave any trailing spaces.
*/
input: string;
/**
* The `id` of the model to be used for this request. Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx).
*/
modelId: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** Properties that control the model and response. */
parameters?: TextGenParameters;
/**
* Properties that control the moderations, for usages such as `Hate and profanity` (HAP) and
* `Personal identifiable information` (PII) filtering. This list can be extended with new types
* of moderations.
*/
moderations?: Moderations;
returnObject?: boolean;
}
/** Parameters for the `textTokenization` operation. */
export interface TextTokenizationParams extends DefaultParams, EncryptionParams {
/**
* The `id` of the model to be used for this request. Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx).
*/
modelId: string;
/** The input string to tokenize. */
input: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** The parameters for text tokenization. */
parameters?: TextTokenizeParameters;
}
/** Parameters for the `trainingsCreate` operation. */
export interface TrainingsCreateParams extends DefaultParams {
/** The name of the training. */
name: string;
/**
* The training results. Normally this is specified as `type=container` which means that it is
* stored in the space or project.
*/
resultsReference: ObjectLocation;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** A description of the training. */
description?: string;
/** A list of tags for this resource. */
tags?: string[];
/** Properties to control the prompt tuning. */
promptTuning?: PromptTuning;
/** Training datasets. */
trainingDataReferences?: DataConnectionReference[];
/** User defined properties specified as key-value pairs. */
custom?: JsonObject;
/**
* If set to `true` then the result of the training, if successful, will be uploaded to the
* repository as a model.
*/
autoUpdateModel?: boolean;
}
/** Parameters for the `trainingsList` operation. */
export interface TrainingsListParams extends DefaultParams {
/**
* Token required for token-based pagination. This token cannot be determined by end user. It is
* generated by the service and it is set in the href available in the `next` field.
*/
start?: string;
/** How many resources should be returned. By default limit is 100. Max limit allowed is 200. */
limit?: number;
/** Compute the total count. May have performance impact. */
totalCount?: boolean;
/** Return only the resources with the given tag value. */
tagValue?: string;
/** Filter based on on the training job state. */
state?: TrainingsListConstants.State | string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Constants for the `trainingsList` operation. */
export declare namespace TrainingsListConstants {
/** Filter based on on the training job state. */
enum State {
QUEUED = "queued",
PENDING = "pending",
RUNNING = "running",
STORING = "storing",
COMPLETED = "completed",
FAILED = "failed",
CANCELED = "canceled"
}
}
/** Parameters for the `trainingsGet` operation. */
export interface TrainingsGetParams extends DefaultParams {
/** The training identifier. */
trainingId: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
}
/** Parameters for the `trainingsDelete` operation. */
export interface TrainingsDeleteParams extends DefaultParams {
/** The training identifier. */
trainingId: string;
/**
* The space that contains the resource. Either `space_id` or `project_id` query parameter has to
* be given.
*/
spaceId?: string;
/**
* The project that contains the resource. Either `space_id` or `project_id` query parameter has
* to be given.
*/
projectId?: string;
/** Set to true in order to also delete the job or request metadata. */
hardDelete?: boolean;
}
/** Parameters for the `textRerank` operation. */
export interface TextRerankParams extends DefaultParams, EncryptionParams {
/**
* The `id` of the model to be used for this request. Please refer to the [list of
* models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models-embed.html?context=wx&audience=wdp).
*/
modelId: string;
/** The rank input strings. */
inputs: RerankInput[];
/** The rank query. */
query: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** The properties used for reranking. */
parameters?: RerankParameters;
}
/** Parameters for the `timeSeriesForecast` operation. */
export interface TimeSeriesForecastParams extends DefaultParams {
/** The model to be used for generating a forecast. */
modelId: string;
/**
* A payload of data matching `schema`. We assume the following about your data:
*
* - All timeseries are of equal length and are uniform in nature (the time difference between two
* successive rows is constant). This implies that there are no missing rows of data;
* - The data meet the minimum model-dependent historical context length which can be 512 or more
* rows per timeseries;
*
* Note that the example payloads shown are for illustration purposes only. An actual payload
* would necessary be much larger to meet minimum model-specific context lengths.
*/
data: JsonObject;
/** Contains metadata about your timeseries data input. */
schema: TSForecastInputSchema;
/** The project that contains the resource. Either `space_id` or `project_id` has to be given. */
projectId?: string;
/** The space that contains the resource. Either `space_id` or `project_id` has to be given. */
spaceId?: string;
/** The parameters for the forecast request. */
parameters?: TSFo