Hierarchy

  • BaseService
    • WatsonXAI

Constructors

Properties

version: string

The version date for the API of the form YYYY-MM-DD.

wxServiceUrl: string
wxServiceUrl: string

Methods - Deployments

  • Infer text event stream.

    Infer the next tokens for a given deployed model with a set of parameters. This operation will return the output tokens as a stream of events. If a serving_name is used then it must match the serving_name that is returned in the inference when the deployment was created.

    Return options

    Note that there is currently a limitation in this operation when using return_options, for input only input_text will be returned if requested, for output the input_tokens and generated_tokens will not be returned, also the rank and top_tokens will not be returned.

    Parameters

    Returns Promise<WatsonXAI.Response<WatsonXAI.TextGenResponse[]>>

Methods - Embeddings

Methods - Foundation Model Specs

Methods - Notebooks

  • Create a new notebook.

    Create a new notebook

    • either from scratch
    • or by copying another notebook.

    To create a notebook from scratch, you need to first upload the notebook content(ipynb format) to the project Cloud Object Storage (COS) and then reference it with the attribute file_reference. The other required attributes are name, project and runtime. The attribute runtime is used to specify the environment on which the notebook runs.

    To copy a notebook, you only need to provide name and source_guid in the request body.

    Parameters

    Returns Promise<WatsonXAI.Response<WatsonXAI.NotebooksCreateResponse>>

Methods - Prompt Sessions

Methods - Prompts / Prompt Templates

Methods - Text Generation

Methods - Tokenization

Methods - Trainings

  • Create a new watsonx.ai training.

    Create a new watsonx.ai training in a project or a space.

    The details of the base model and parameters for the training must be provided in the prompt_tuning object.

    In order to deploy the tuned model you need to follow the following steps:

    1. Create a WML model asset, in a space or a project, by providing the request.json as shown below:

      curl -X POST 'https://{cpd_cluster}/ml/v4/models?version=2024-01-29' \
      -H 'Authorization: Bearer <replace with your token>' \
      -H 'content-type: application/json' \
      --data '{
      'name': 'replace_with_a_meaningful_name',
      'space_id': 'replace_with_your_space_id',
      'type': 'prompt_tune_1.0',
      'software_spec': {
      'name': 'watsonx-textgen-fm-1.0'
      },
      'metrics': [ from the training job ],
      'training': {
      'id': '05859469-b25b-420e-aefe-4a5cb6b595eb',
      'base_model': {
      'model_id': 'google/flan-t5-xl'
      },
      'task_id': 'generation',
      'verbalizer': 'Input: {{input}} Output:'
      },
      'training_data_references': [
      {
      'connection': {
      'id': '20933468-7e8a-4706-bc90-f0a09332b263'
      },
      'id': 'file_to_tune1.json',
      'location': {
      'bucket': 'wxproject-donotdelete-pr-xeyivy0rx3vrbl',
      'path': 'file_to_tune1.json'
      },
      'type': 'connection_asset'
      }
      ]
      }'

      Notes:

      1. If you used the training request field auto_update_model: true then you can skip this step as the model will have been saved at the end of the training job.
      2. Rather than creating the payload for the model you can use the generated request.json that was stored in the results_reference field, look for the path in the field entity.results_reference.location.model_request_path.
      3. The model type must be prompt_tune_1.0.
      4. The software spec name must be watsonx-textgen-fm-1.0.
    2. Create a tuned model deployment as described in the create deployment documentation.

    Parameters

    Returns Promise<WatsonXAI.Response<WatsonXAI.TrainingResource>>

Methods - constructor

  • Constructs an instance of WatsonxAiMlVmlv1 with passed in options and external configuration.

    Parameters

    • Optional options: UserOptions

      The parameters to send to the service.

    Returns WatsonXAI

Methods - Other

  • Constructs a service URL by formatting the parameterized service URL.

    The parameterized service URL is: 'https://{region}.ml.cloud.ibm.com'

    The default variable values are:

    • 'region': 'us-south'

    Parameters

    • providedUrlVariables: Map<string, string>

    Returns string

    The formatted URL with all variable placeholders replaced by values.