AI_AlterModel
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 |
A custom name for the model. It must be unique for easy model management. Make sure to distinguish it from Note
The custom model name cannot start with an underscore (_). When the Polar_AI extension is created, the system automatically creates a set of built-in models whose names start with an underscore (_). You can run the following statement to view the created models: |
|
model_url |
The endpoint of the model. It cannot be empty. HTTP, HTTPS, and FILE protocols are supported. Example: the HTTP endpoint of the general-purpose text embedding model in Model Studio |
|
model_provider |
The model provider. It can be empty. Examples: AWS, Alibaba, Baidu, and Tencent. |
|
model_type |
The model type. It can be empty. Examples: LSTM and GRU. |
|
model_name |
The name of the model to call. It cannot be empty. Example: text-embedding-v2. |
|
model_config |
The model configuration information in JSON format. It cannot be empty. Format: { "author_type":"token", "token":"<YOUR_API_KEY>" }, where:
|
|
model_headers_fn |
The request header function that constructs request headers. The return type must be JSONB. If the model has no special header requirements, leave this parameter empty. Default: empty. |
|
model_in_transform_fn |
The input transform function. It cannot be empty. It is used to construct request data. For more information, see Input transform function. |
|
model_out_transform_fn |
The output transform function. It cannot be empty. It is used to parse the data returned by the model. For more information, see Output transform function. |
Return values
|
Value |
Description |
|
t |
The modification succeeded. |
|
f |
The modification failed. |
Usage notes
-
Only model_id is required. All other parameters are optional. If a parameter is set to NULL, the corresponding field is not modified.
-
When modifying model information, make sure that model_url and model_config are accurate. If either parameter is specified, its value must not be NULL. Otherwise, the call fails.
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"}');Setting model_config to NULL causes the call to fail:
SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_config=>NULL); --- f