All Products
Search
Document Center

PolarDB:AI_AlterModel

Last Updated:May 19, 2025

Modifies AI model information.

Syntax

boolean AI_AlterModel(text model_id, text model_url, text model_provider, text model_type, text model_name, text model_config, regprocedure model_headers_fn, regprocedure model_in_transform_fn, regprocedure model_out_transform_fn);

Parameters

Parameter

Description

model_id

The unique identifier of the AI model. The value must be different from that of the model_name parameter.

Note

The identifier of the AI model cannot start with an underscore (_). When you create the Polar_AI extension, the system automatically creates a set of built-in AI models that start with an underscore (_). To view the AI models, execute the SELECT * FROM polar_ai._ai_models; statement.

model_url

The URL used to access the AI model. The value cannot be NULL. Supported protocols include HTTP, HTTPS, and FILE. For example, the URL can be the endpoint included in the call information of the model that is deployed on Platform for AI (PAI).

model_provider

The provider of the AI model. The value can be NULL. Examples: AWS, Alibaba, Baidu, and Tencent.

model_type

The type of the AI model. The value can be NULL. Examples: LSTM and GRU.

model_name

The name of the AI model. The value cannot be NULL. Example: text-embedding-v2.

model_config

The configuration information of the AI model. Specify the value in the JSON format. The value cannot be NULL. The format is: { "author_type":"token", "token":"<YOUR_API_KEY>" }.

  • You must specify the author_type and token fields. author_type specifies the authentication type. Only token-based authentication is supported.

  • The token field contains the API key used to invoke the model. API keys are encrypted when stored to ensure security. For example, the value can be the token included in the call information of the model that is deployed on PAI.

model_headers_fn

The function used to construct the request headers. The returned value is in the JSONB format. If the model has no special header requirements, you do not need to configure this parameter. Default value: NULL.

model_in_transform_fn

The function used to convert the input data to a valid format. The value cannot be NULL.

model_out_transform_fn

The function used to parse and transform the output data returned by the AI model. The value cannot be NULL.

Return values

Return value

Description

t

The modification was successful.

f

The modification failed.

Description

  • You must specify the model_id parameter. All other parameters are optional. If a parameter is set to NULL, the function does not modify the corresponding field in the model's configuration.

  • If you specify the model_url and model_config parameters when you modify the information of an AI model, make sure that these parameters are accurate and not NULL. Otherwise, the model fails to be called.

Examples

  • SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_url=>'http://....');
  • SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_provider=>'Alibaba');
  • SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_type=>'GRU');
  • SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_name=>'text-embedding-v3');
  • SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_config=>'{"token": "your-new-api-key", "author_type": "token"}');

    In the following example, the AI model fails to be called because the model_config parameter is set to NULL.

    SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_config=>NULL);
    ---
    f