Qianfan Knowledgebase Search Skill
Search and retrieve knowledge from Baidu Qianfan platform knowledge bases. Supports semantic search, fulltext search, hybrid search, and reranking.
Workflow
- The skill executes the Python script located at
search.py
- The script makes a POST request to the Qianfan Knowledgebase Search API
- The API returns structured search results with chunks, scores, and metadata
Environment Variables
| env |
required |
description |
| BAIDU_API_KEY |
yes |
Qianfan platform API Key |
| QIANFAN_KNOWLEDGEBASE_IDS |
no |
Knowledgebase IDs, comma-separated (used if not specified in request) |
Parameters
request body structure
| param |
type |
required |
default |
description |
| query |
str |
yes |
|
Search query content |
| knowledgebase_ids |
list[str] |
no |
|
Knowledgebase ID list (uses env var if not specified) |
| top_k |
int |
no |
6 |
Number of chunks to return, range [1, 40] |
| score_threshold |
float |
no |
0.4 |
Score threshold for filtering, range [0, 1] |
| enable_graph |
bool |
no |
false |
Enable knowledge graph |
| enable_expansion |
bool |
no |
false |
Return expanded chunks |
| recall |
obj |
no |
|
Recall strategy configuration |
| +recall.type |
str |
no |
hybrid |
Recall type: fulltext/semantic/hybrid |
| +recall.top_k |
int |
no |
100 |
Recall phase top_k, range [1, 400] |
| +recall.vec_weight |
float |
no |
0.75 |
Vector weight when type=hybrid, range [0, 1] |
| rerank |
obj |
no |
|
Rerank configuration |
| +rerank.enable |
bool |
no |
true |
Enable reranking |
| +rerank.top_n |
int |
no |
20 |
Rerank top_n, range [1, 40] |
Note: Use flattened parameter names in input (e.g., recall_type, recall_top_k), the script will convert to nested structure automatically.
Example Usage
# Configure knowledgebase IDs via environment variable
export BAIDU_API_KEY="your_api_key"
export QIANFAN_KNOWLEDGEBASE_IDS="kb_id_1,kb_id_2"
python3 skills/qianfan-knowledgebase-search/search.py '{"query":"请介绍下千帆大模型知识库"}'
# Or specify knowledgebase IDs in request parameters
python3 skills/qianfan-knowledgebase-search/search.py '{"query":"如何使用API","knowledgebase_ids":["kb_id_1","kb_id_2"],"top_k":10,"recall_type":"hybrid","rerank_enable":true}'
Response Structure
Response contains the following fields:
- id: Request unique identifier
- created_at: Request timestamp
- total_count: Total number of chunks returned
- chunks: Chunk list
- chunk_id: Chunk unique identifier
- content: Chunk content (supports text/figure/table/graph types)
- rerank: Rerank score and position
- recall: Recall score and position
- meta: Metadata (chunk_type, tokens, word_count, doc_info, etc.)
- neighbors: Related chunks
Current Status
The Qianfan Knowledgebase Search skill is fully functional and can be used to retrieve knowledge from private knowledge bases on the Baidu Qianfan platform.
1---
2name: qianfan-knowledgebase-search
3description: Search knowledge from Qianfan Knowledgebase. Use this when you need to retrieve information from user's private knowledge bases on Baidu Qianfan platform.
4metadata:
5 source: https://skillmd.com/skills/modbender/qianfan-knowledgebase-search
6 openclaw:
7 emoji: 📚
8 requires:
9 bins:
10 - python3
11 env:
12 - BAIDU_API_KEY
13 - QIANFAN_KNOWLEDGEBASE_IDS
14 primaryEnv: BAIDU_API_KEY
15---
16
17# Qianfan Knowledgebase Search Skill
18
19Search and retrieve knowledge from Baidu Qianfan platform knowledge bases. Supports semantic search, fulltext search, hybrid search, and reranking.
20
21## Workflow
22
231. The skill executes the Python script located at `search.py`
242. The script makes a POST request to the Qianfan Knowledgebase Search API
253. The API returns structured search results with chunks, scores, and metadata
26
27## Environment Variables
28
29| env | required | description |
30|-----|----------|-------------|
31| BAIDU_API_KEY | yes | Qianfan platform API Key |
32| QIANFAN_KNOWLEDGEBASE_IDS | no | Knowledgebase IDs, comma-separated (used if not specified in request) |
33
34## Parameters
35
36#### request body structure
37| param | type | required | default | description |
38|-------|------|----------|---------|-------------|
39| query | str | yes | | Search query content |
40| knowledgebase_ids | list[str] | no | | Knowledgebase ID list (uses env var if not specified) |
41| top_k | int | no | 6 | Number of chunks to return, range [1, 40] |
42| score_threshold | float | no | 0.4 | Score threshold for filtering, range [0, 1] |
43| enable_graph | bool | no | false | Enable knowledge graph |
44| enable_expansion | bool | no | false | Return expanded chunks |
45| recall | obj | no | | Recall strategy configuration |
46| +recall.type | str | no | hybrid | Recall type: fulltext/semantic/hybrid |
47| +recall.top_k | int | no | 100 | Recall phase top_k, range [1, 400] |
48| +recall.vec_weight | float | no | 0.75 | Vector weight when type=hybrid, range [0, 1] |
49| rerank | obj | no | | Rerank configuration |
50| +rerank.enable | bool | no | true | Enable reranking |
51| +rerank.top_n | int | no | 20 | Rerank top_n, range [1, 40] |
52
53> Note: Use flattened parameter names in input (e.g., `recall_type`, `recall_top_k`), the script will convert to nested structure automatically.
54
55## Example Usage
56
57```bash
58# Configure knowledgebase IDs via environment variable
59export BAIDU_API_KEY="your_api_key"
60export QIANFAN_KNOWLEDGEBASE_IDS="kb_id_1,kb_id_2"
61python3 skills/qianfan-knowledgebase-search/search.py '{"query":"请介绍下千帆大模型知识库"}'
62```
63
64```bash
65# Or specify knowledgebase IDs in request parameters
66python3 skills/qianfan-knowledgebase-search/search.py '{"query":"如何使用API","knowledgebase_ids":["kb_id_1","kb_id_2"],"top_k":10,"recall_type":"hybrid","rerank_enable":true}'
67```
68
69## Response Structure
70
71Response contains the following fields:
72
73- **id**: Request unique identifier
74- **created_at**: Request timestamp
75- **total_count**: Total number of chunks returned
76- **chunks**: Chunk list
77 - **chunk_id**: Chunk unique identifier
78 - **content**: Chunk content (supports text/figure/table/graph types)
79 - **rerank**: Rerank score and position
80 - **recall**: Recall score and position
81 - **meta**: Metadata (chunk_type, tokens, word_count, doc_info, etc.)
82 - **neighbors**: Related chunks
83
84## Current Status
85
86The Qianfan Knowledgebase Search skill is fully functional and can be used to retrieve knowledge from private knowledge bases on the Baidu Qianfan platform.