Skip to content

Usage


watsonx main functionality

Function: watsonx_generate

Description: calls a large language model in dbsdk_v1.ai to generate a response based on the input message. Input parameters:

  • TEXT (required): The prompt text for the LLM.
  • MODEL_ID (optional): The watsonx model ID to use (default: meta-llama/llama-2-13b-chat).
  • PARAMETERS (optional): Extra parameters to the watsonx generation APIs.

Return type:

  • varchar(10000) ccsid 1208

Return value:

  • The generated text

Model list

Function: watsonx_getmodels

Description: Calls dbsdk_v1.ai to list available model ids for use with this API.

Input parameters:

  • TEXT (required): The prompt text for the LLM.
  • MODEL_ID (optional): The watsonx model ID to use (default: meta-llama/llama-2-13b-chat).
  • PARAMETERS (optional): Extra parameters to the watsonx generation APIs.

Return type:

  • Result set with the following columns:
    • model_id: The model ID.
    • label: The model label.
    • provider : The model provider.
    • short_description: A short description of the model.

Return value:

  • The list of available models

Authorization functions

Function: watsonx_authenticate

Description: authenticates to the watsonx service and acquires an access token.

Return type:

  • char(1) ccsid 1208

Return value:

  • Either Y or N, depending on whether the authentication was successful.

Utility functions

Function: watsonx_SetApiKeyForJob

Description: Sets the watsonx API key to be used for the current job

Input parameters:

  • APIKEY (required): The API key.

Function: watsonx_SetProjectIdForJob

Description: Sets the watsonx project ID to be used for the current job

Input parameters:

  • PROJECTID (required): The project ID.

Function: watsonx_logoutJob

Description: Log out from teh current job.