当前位置: 首页 > Skill >

Alibabacloud Analyticdb Postgresql Knowledgebase Ops

Alibabacloud Analyticdb Postgresql Knowledgebase Ops

0.0.2 2026.11.15 浏览:425
获取Skill文件查看使用说明
作者:陈辰许可证:
本文目录展开

ADBPG Knowledge Base Management

Build enterprise knowledge bases in three steps: Create Knowledge Base → Upload Documents → Search & Q&A

The system automatically handles document parsing, chunking, vectorization, and index building. Users only need to focus on business logic.

Architecture: ADBPG Instance + Namespace + DocumentCollection + Vector Index + LLM Service

Core Concepts

  • Knowledge Base: Container for documents, automatically manages vector indexes (corresponds to DocumentCollection in API)
  • Document: Files uploaded to the knowledge base, supports PDF/Word/Markdown/HTML/JSON/CSV/images, etc.
  • Q&A: Intelligent conversation based on knowledge base + large language model

Environment Setup

[MUST] CLI User-Agent — Every aliyun CLI command invocation must include: --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:

aliyun 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.

aliyun configure ai-mode disable

Pre-check: Aliyun CLI >= 3.3.3 required Run aliyun version to verify >= 3.3.3. If not installed or version too low, run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to install/update, or see references/cli-installation-guide.md for installation instructions. Then [MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation. Then [MUST] run aliyun plugin update to ensure that any existing plugins on your local machine are always up-to-date.

Pre-check: Alibaba Cloud Credentials Required

Security 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 aliyun configure set with literal credential values
  • ONLY use aliyun configure list to check credential status
aliyun configure list

Check the output for a valid profile (AK, STS, or OAuth identity).

If no valid profile exists, STOP here.

  1. Obtain credentials from Alibaba Cloud Console
  2. Configure credentials outside of this session (via aliyun configure in terminal or environment variables in shell profile)
  3. Return and re-run after aliyun configure list shows a valid profile

Verify CLI Credentials

aliyun gpdb describe-regions --user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-postgresql-knowledgebase-ops

Script dependencies (Python)

scripts/upload_document_local.py uses the Alibaba Cloud Python SDK. Declare dependencies in requirements.txt. Install before running the script:

pip install -r requirements.txt

Requires Python 3.7+ (same baseline as Alibaba Cloud SDK for Python).

RAM Permissions

[MUST] RAM Permission Pre-check: Before executing operations, verify current user has required permissions. Use ram-permission-diagnose skill to check permissions, then compare against references/ram-policies.md. If any permission is missing, abort and prompt user.

Parameter Confirmation

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.

For interaction guidelines, smart defaults, and best practices, see references/interaction-guidelines.md.

Documentation placeholders: CLI examples use strings like <manager-account-password> and <namespace-password>. Replace them with real values from the user; never commit or log real passwords in docs, tickets, or chat.

Timeout Configuration

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)

CLI Timeout Settings:

# 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 10

Python SDK (default credential chain + timeouts + User-Agent):

Use CredentialClient() with no arguments so the SDK resolves credentials via the default chain (same sources as the CLI). Do not parse credential files or pass raw keys in skill code. Set user_agent and HTTP timeouts on Config (milliseconds).

from 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',
))

Core Workflow

1. Knowledge Base Management

Create Knowledge Base

Pre-checks (run in order; not silent idempotency):

  • Duplicate names: If a create step is run again when the resource already exists, the API returns a clear error (e.g. conflict / already exists). Do not create duplicate resources; interpret already-exists-style errors as “this step is satisfied” only when the response clearly indicates the resource is present, then continue the workflow.
  • Retries / ClientToken: For network-level retries (e.g. timeout), use ClientToken when the API or aliyun gpdb exposes it for that subcommand—check aliyun gpdb <subcommand> --help. The examples below omit it when the plugin does not list it globally.
# 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-ops

Important: CreateNamespace MUST be executed before CreateDocumentCollection

Create knowledge base:

# 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-ops

List Knowledge Bases

aliyun 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-ops

List Namespaces

aliyun 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-ops

2. Document Management

Upload Document (Public URL)

aliyun 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-ops

Upload Document (Local File - SDK)

Local files use Python SDK upload_document_async_advance. Do not paste multi-line Python into the skill; use the packaged script only (default credential chain, user_agent, Config timeouts, and RuntimeOptions timeouts — see scripts/upload_document_local.py).

python3 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.pdf

See scripts/upload_document_local.py.

Poll Upload Progress

aliyun 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-ops

List Documents

aliyun 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-ops

3. Search & Q&A

Search Knowledge Base

aliyun 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-ops

Knowledge Base Q&A

aliyun 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

Reference Links

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 scripts/

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,033
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,012
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,012
Skill 文件
  • SKILL.md
    • ADBPG Knowledge Base Management
    • Core Concepts
    • Environment Setup
      • Verify CLI Credentials
      • Script dependencies (Python)
    • RAM Permissions
    • Parameter Confirmation
    • Timeout Configuration
    • Core Workflow
      • 1. Knowledge Base Management
        • Create Knowledge Base
        • List Knowledge Bases
        • List Namespaces
      • 2. Document Management
        • Upload Document (Public URL)
        • Upload Document (Local File - SDK)
        • Poll Upload Progress
        • List Documents
      • 3. Search & Q&A
        • Search Knowledge Base
        • Knowledge Base Q&A
    • Reference Links
  • 项目或源文件

相关 Skill

更多
Alibabacloud Rds Postgresql Inspection Alibabacloud Rds Postgresql Inspection 批量健康检查阿里云RDS PostgreSQL实例,生成包含资源使用、告警、慢日志、长事务和复制等信息的详细HTML报告。
Claimable Postgres Claimable Postgres 通过 Neon 的 Claimable Postgres (neon.new) 即时创建临时 Postgres 数据库,无需登录、注册或信用卡,支持 REST API、CLI 等方式。
postgresql-skill postgresql-skill 使用psycopg2执行PostgreSQL数据库操作,列出表、描述模式、执行SQL查询。
Add Postgres-native vector retrieval to agent and RAG workflows with pgvector Add Postgres-native vector retrieval to agent and RAG workflows with pgvector 将嵌入向量存储在 Postgres 中的应用数据旁边,创建向量索引,并查询最近邻以进行语义搜索、RAG、推荐或代理内存检索。
MySQL to PostgreSQL Migration MySQL to PostgreSQL Migration 在将项目数据库层从MySQL迁移到PostgreSQL时使用此技能。覆盖SQL方言转换(MyBatis XML/原始SQL)和ORM配置等...