Search and query knowledge bases directly from the terminal with the Bailian CLI.
The Bailian CLI wraps knowledge-base search and Q&A into commands you can drive from the terminal or an Agent.
Replace the service and workspace IDs before running:
CLI 2.5.0 removed
Knowledge-base CLI capabilities are currently available only to China site (aliyun.com) accounts.
Prerequisites
- Install Bailian CLI and configure an API key and workspace ID.
- Create a retrieval or Q&A service, bind the target knowledge base, and publish it. See Knowledge Retrieval and Knowledge Q&A.
--agent-id, not a knowledge base ID. Configure retrieval scope, result counts, and reranking in the service.
Commands
| Capability | Command | Notes | Common options |
|---|---|---|---|
| Semantic search | bl knowledge search | Calls a published retrieval service to run semantic search | --query query text, --agent-id retrieval service ID |
| RAG Q&A | bl knowledge chat | Calls a published Q&A service for RAG Q&A with streaming output | --message message text, --agent-id Q&A service ID |
Example
Replace the service and workspace IDs before running:
bl knowledge retrieve and kscli retrieve. Scripts that retrieved directly by knowledge base ID must switch to a retrieval service with bl knowledge search or kscli search; the old --index-id value and retrieval parameters cannot be carried over directly.
Append --help to any command for full parameter details. See the RAG command reference for more commands.