Skip to main content
Version: V1.1.0

Register and manage AI models and endpoints

This topic describes how to register and manage AI models and endpoints in seekdb.

Prerequisites​

  • You have the required permissions for AI models. For more information, see Manage AI model permissions.
  • You have obtained the API key for the third-party model service.

Register and manage AI models and endpoints by using the system package​

The DBMS_AI_SERVICE package provides the ability to manage AI models and endpoints. It supports the following operations:

OperationDescription
CREATE_AI_MODELCreates an AI model object.
DROP_AI_MODELDrops an AI model object.
CREATE_AI_MODEL_ENDPOINTCreates an AI model endpoint object.
ALTER_AI_MODEL_ENDPOINTModifies an AI model endpoint object.
DROP_AI_MODEL_ENDPOINTDrops an AI model endpoint object.

You can call this system package to directly manage AI models and endpoints in seekdb without relying on external services. For more information about the parameters and syntax, see DBMS_AI_SERVICE.

tip

For more information about the supported AI model providers and their corresponding URLs, see CREATE_AI_MODEL_ENDPOINT.

Register Model and endpoint templates​

Register the model and the endpoint of the model by executing the CREATE_AI_MODEL and CREATE_AI_MODEL_ENDPOINT statements, respectively. The following example registers three model keys ob_complete, ob_embed, and ob_rerank to be used for text generation (AI_COMPLETE), vector embedding (AI_EMBED), and reranking (AI_RERANK). Replace access_key with your actual API key.

info

If you want to use only a specific category of AI function, you can register only the model and endpoint corresponding to the function. For example, if you want to use only AI_COMPLETE, you only need to complete the Register Text Generation Model and Endpoint step below.

Register an embedded model and endpoint​

Used with AI_EMBED.

This example shows how to register an embedding model and endpoint for Alibaba Cloud (compatible with the OpenAI format).

CALL DBMS_AI_SERVICE.DROP_AI_MODEL ('ob_embed');
CALL DBMS_AI_SERVICE.DROP_AI_MODEL_ENDPOINT ('ob_embed_endpoint');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL(
'ob_embed', '{
"type": "dense_embedding",
"model_name": "BAAI/bge-m3"
}');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL_ENDPOINT (
'ob_embed_endpoint', '{
"ai_model_name": "ob_embed",
"url": "https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings",
-- Replace this with the actual access key
"access_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"provider": "aliyun-openAI"
}');

Register text generation models and endpoints​

Used for AI_COMPLETE and AI_PROMPT.

This example demonstrates how to register a text generation model and endpoint compatible with the OpenAI format on Alibaba Cloud.

CALL DBMS_AI_SERVICE.DROP_AI_MODEL ('ob_complete');
CALL DBMS_AI_SERVICE.DROP_AI_MODEL_ENDPOINT ('ob_complete_endpoint');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL(
'ob_complete', '{
"type": "completion",
"model_name": "THUDM/GLM-4-9B-0414"
}');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL_ENDPOINT (
'ob_complete_endpoint', '{
"ai_model_name": "ob_complete",
"url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
-- Replace with a valid access key.
"access_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"provider": "aliyun-openAI"
}');

Register reranking models and endpoints​

This sample registers a reranking model and endpoint for Alibaba Cloud DashScope, which is not in OpenAI API format.

CALL DBMS_AI_SERVICE.DROP_AI_MODEL ('ob_rerank');
CALL DBMS_AI_SERVICE.DROP_AI_MODEL_ENDPOINT ('ob_rerank_endpoint');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL(
'ob_rerank', '{
"type": "rerank",
"model_name": "BAAI/bge-reranker-v2-m3"
}');

CALL DBMS_AI_SERVICE.CREATE_AI_MODEL_ENDPOINT (
'ob_rerank_endpoint', '{
"ai_model_name": "ob_rerank",
"url": "https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank",
-- Replace the access key with a valid one.
"access_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"provider": "aliyun-dashscope"
}');

View information about AI models and endpoints​

seekdb allows you to view information about AI models and endpoints by using views:

ViewDescription
CDB/DBA_OB_AI_MODELSViews information about AI models.
CDB/DBA_OB_AI_MODEL_ENDPOINTSViews information about AI model endpoints.