Loading...
Loading...
ADBPG Knowledge Base Management: Create knowledge bases, upload documents, search, Q&A. Triggers: "knowledge base", "document library", "document upload", "knowledge search", "RAG", "Q&A", "embedding", "ADBPG", "AnalyticDB PostgreSQL"
npx skill4agent add aliyun/alibabacloud-aiops-skills alibabacloud-analyticdb-postgresql-knowledgebase-opsADBPG Instance + Namespace + DocumentCollection + Vector Index + LLM Servicealiyun--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops[MUST] Enable AI-Mode — AI-mode is required for Agent Skill execution. Run the following commands before any CLI invocation:bashaliyun configure ai-mode enable aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops"
[MUST] Disable AI-Mode at EVERY exit point — Before delivering the final response for ANY reason, always disable AI-mode first. This applies to ALL exit paths: workflow success, workflow failure, error/exception, user cancellation, session end, or any other scenario where no further CLI commands will be executed. AI-mode is only used for Agent Skill invocation scenarios and MUST NOT remain enabled after the skill stops running.bashaliyun configure ai-mode disable
Pre-check: Aliyun CLI >= 3.3.3 required Runto verify >= 3.3.3. If not installed or version too low, runaliyun versionto install/update, or see references/cli-installation-guide.md for installation instructions. Then [MUST] runcurl -fsSL https://aliyuncli.alicdn.com/setup.sh | bashto enable automatic plugin installation. Then [MUST] runaliyun configure set --auto-plugin-install trueto ensure that any existing plugins on your local machine are always up-to-date.aliyun plugin update
Pre-check: Alibaba Cloud Credentials RequiredSecurity Rules:
- NEVER read, echo, or print credential material (including environment-based secrets)
- NEVER ask the user to paste long-lived secrets directly in the conversation or command line
- NEVER use
with literal credential valuesaliyun configure set- ONLY use
to check credential statusaliyun configure listbashaliyun configure listCheck the output for a valid profile (AK, STS, or OAuth identity).If no valid profile exists, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
in terminal or environment variables in shell profile)aliyun configure- Return and re-run after
shows a valid profilealiyun configure list
aliyun gpdb describe-regions --user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsscripts/upload_document_local.pyrequirements.txtpip install -r requirements.txt[MUST] RAM Permission Pre-check: Before executing operations, verify current user has required permissions. Useskill to check permissions, then compare against references/ram-policies.md. If any permission is missing, abort and prompt user.ram-permission-diagnose
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required/Optional | Description | Default Value |
|---|---|---|---|
| biz-region-id | Required | Region ID | cn-hangzhou |
| db-instance-id | Required | Instance ID (format: gp-xxxxx) | - |
| manager-account | Required | Manager account name | - |
| manager-account-password | Required | Manager account password | - |
| namespace | Optional | Namespace name | public |
| namespace-password | Required | Namespace password | - |
| collection | Required | Knowledge base name | - |
| embedding-model | Optional | Embedding model | text-embedding-v4 |
| dimension | Optional | Vector dimension | 1024 |
Note: If the knowledge base is created in a custom namespace, all subsequent operations must specify the same namespace parameter.
Documentation placeholders: CLI examples use strings likeand<manager-account-password>. Replace them with real values from the user; never commit or log real passwords in docs, tickets, or chat.<namespace-password>
Timeout Rules: All operations must complete within reasonable time limits.
- Standard operations: ≤10 seconds (create/list/query)
- Upload document async: No timeout limit (async job, poll every 5-10s)
# Add --ConnectTimeout and --ReadTimeout to all commands
aliyun gpdb create-document-collection \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--manager-account admin_user \
--manager-account-password '<manager-account-password>' \
--namespace ns_my_knowledge_base \
--collection my_knowledge_base \
--embedding-model text-embedding-v4 \
--dimension 1024 \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops \
--ConnectTimeout 10 \
--ReadTimeout 10CredentialClient()user_agentConfigfrom alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_gpdb20160503.client import Client
from alibabacloud_tea_openapi.models import Config
client = Client(Config(
credential=CredentialClient(),
region_id='cn-hangzhou',
endpoint='gpdb.aliyuncs.com',
connect_timeout=10000,
read_timeout=10000,
user_agent='AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops',
))aliyun gpdbaliyun gpdb <subcommand> --help# 1. Initialize vector database
aliyun gpdb init-vector-database \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--manager-account admin_user \
--manager-account-password '<manager-account-password>' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops
# 2. Create namespace (naming rule: ns_{collection}, public is forbidden)
aliyun gpdb create-namespace \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--manager-account admin_user \
--manager-account-password '<manager-account-password>' \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsImportant: CreateNamespace MUST be executed before CreateDocumentCollection
# 3. Create knowledge base (in the previously created namespace)
aliyun gpdb create-document-collection \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--manager-account admin_user \
--manager-account-password '<manager-account-password>' \
--namespace ns_my_knowledge_base \
--collection my_knowledge_base \
--embedding-model text-embedding-v4 \
--dimension 1024 \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb list-document-collections \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb list-namespaces \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--manager-account admin_user \
--manager-account-password '<manager-account-password>' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb upload-document-async \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--collection my_knowledge_base \
--file-name "user_manual.pdf" \
--file-url "https://example.com/user_manual.pdf" \
--document-loader-name ADBPGLoader \
--chunk-size 500 \
--chunk-overlap 50 \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsupload_document_async_advanceuser_agentConfigRuntimeOptionsscripts/upload_document_local.pypython3 scripts/upload_document_local.py \
--region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--collection my_knowledge_base \
--file /path/to/local/file.pdfaliyun gpdb get-upload-document-job \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--collection my_knowledge_base \
--job-id "job-xxxxx" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb list-documents \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--collection my_knowledge_base \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb query-content \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--namespace ns_my_knowledge_base \
--namespace-password '<namespace-password>' \
--collection my_knowledge_base \
--content "How to configure database parameters?" \
--topk 10 \
--rerank-factor 5 \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-opsaliyun gpdb chat-with-knowledge-base \
--biz-region-id cn-hangzhou \
--db-instance-id gp-xxxxx \
--model-params '{"Model":"qwen-max","Messages":[{"Role":"user","Content":"User question"}]}' \
--knowledge-params '{"SourceCollection":[{"Collection":"my_knowledge_base","Namespace":"ns_my_knowledge_base","NamespacePassword":"<namespace-password>","QueryParams":{"TopK":10}}]}' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops| Document | Content |
|---|---|
| references/cli-installation-guide.md | CLI Installation Guide |
| references/ram-policies.md | RAM Permissions List |
| references/related-apis.md | Related APIs |
| references/interaction-guidelines.md | Interaction Guidelines & Best Practices |
| references/verification-method.md | Verification Method |
| references/acceptance-criteria.md | Acceptance Criteria |
| references/SKILL.zh-CN.md | Chinese Version |
| requirements.txt | Python deps for |