ima-knowledge
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "ima-knowledge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-71e2cf90fbf6ece57d9a95435a3d2b134735ef175bfb5deaa0f4d075b01fd21b. Verify the upstream source and version against https://skillhub.cn/skills/user_a4e84a83/ima-knowledge before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
IMA Knowledge Base OpenAPI — for searching, browsing, and reading Tencent IMA knowledge base (ima.qq.com) content, with support for uploading files and web pages to extend the knowledge base. Example triggers: knowledge base, search, view knowledge base, upload file to knowledge base, add web page, knowledge base search.
Introduction source: third_party · user_a4e84a83 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Software, accounts and paid services
- ```bash
- Limits and differences
- node <SCRIPT_PATH>/knowledge-base/scripts/preflight-check.cjs --file "/path/to/file.ext"
- Testing
- Not tested
Browse files
Frontmatter
name: ima-knowledge
slug: ima-knowledge
version: 1.0.0
displayName: IMA 知识库
description: |
IMA 知识库 OpenAPI — 搜索、浏览、读取腾讯IMA知识库内容,支持上传文件和网页。
触发词:知识库、搜一下、看看知识库、上传文件到知识库、添加网页、知识库搜索。
当需要访问用户的 IMA 知识库(ima.qq.com)时使用。IMA 知识库
通过 IMA OpenAPI 访问腾讯ima知识库,支持读取(搜索/浏览)和写入(上传文件/添加网页)两类操作。
初始化
- 凭证获取:
get-token.ps1/get-token.sh自动处理(优先平台代理 → 次选环境变量 → 末选配置文件) - API Base:
https://ima.qq.com - 所有 API 均为 HTTP POST + JSON,路径前缀
/openapi/wiki/v1/
凭证内联调用模板
# bash — <SCRIPT_PATH> 替换为脚本所在目录的绝对路径
CREDS=$(bash '<SCRIPT_PATH>/get-token.sh')
curl -s -X POST "https://ima.qq.com/openapi/wiki/v1/<API_PATH>" \
-H "ima-openapi-clientid: $(echo "$CREDS" | jq -r .client_id)" \
-H "ima-openapi-apikey: $(echo "$CREDS" | jq -r .api_key)" \
-H "Content-Type: application/json" \
-d '<JSON_BODY>'
# PowerShell
$creds = & "<SCRIPT_PATH>\get-token.ps1" | ConvertFrom-Json
$headers = @{
"ima-openapi-clientid" = $creds.client_id
"ima-openapi-apikey" = $creds.api_key
}
Invoke-RestMethod -Uri "https://ima.qq.com/openapi/wiki/v1/<API_PATH>" `
-Method Post -Headers $headers -ContentType "application/json" `
-Body ($body | ConvertTo-Json -Depth 10)
快速决策
| 用户意图 | API | 关键参数 |
|---|---|---|
| 在知识库中搜索关键词 | search_knowledge |
query, knowledge_base_id |
| 浏览知识库内容/文件夹 | get_knowledge_list |
knowledge_base_id, folder_id |
| 获取知识库信息(名称/描述) | get_knowledge_base |
ids |
| 查看自己有哪些知识库 | search_knowledge_base |
query: "" |
| 搜索知识库(按名称) | search_knowledge_base |
query: "名称" |
| 上传文件到知识库 | create_media → COS → add_knowledge |
见「上传文件」章节 |
| 添加网页/微信文章 | import_urls |
urls, knowledge_base_id |
| 检查文件名是否重复 | check_repeated_names |
params, knowledge_base_id |
搜索知识库内容
ima_api "openapi/wiki/v1/search_knowledge" '{
"query": "关键词",
"knowledge_base_id": "<kb_id>",
"cursor": ""
}'
# 返回: info_list[media_id, title, parent_folder_id, highlight_content]
# 翻页: cursor=next_cursor, is_end=true 停止
浏览知识库内容
# 根目录
ima_api "openapi/wiki/v1/get_knowledge_list" '{
"knowledge_base_id": "<kb_id>",
"cursor": "",
"limit": 50
}'
# 指定文件夹(folder_id 以 folder_ 开头)
ima_api "openapi/wiki/v1/get_knowledge_list" '{
"knowledge_base_id": "<kb_id>",
"folder_id": "<folder_id>",
"cursor": "",
"limit": 50
}'
# 返回: knowledge_list, current_path(面包屑), is_end, next_cursor
搜索/列出知识库
# 列出用户所有知识库
ima_api "openapi/wiki/v1/search_knowledge_base" '{
"query": "",
"cursor": "",
"limit": 20
}'
# 按名称搜索知识库
ima_api "openapi/wiki/v1/search_knowledge_base" '{
"query": "产品",
"cursor": "",
"limit": 20
}'
# 获取知识库详情(可传入1-20个ID)
ima_api "openapi/wiki/v1/get_knowledge_base" '{
"ids": ["<kb_id>"]
}'
# 返回: infos[kb_id] → {id, name, cover_url, description, recommended_questions}
上传文件到知识库
前置检查
# 自动检测文件类型和大小限制
node <SCRIPT_PATH>/knowledge-base/scripts/preflight-check.cjs --file "/path/to/file.ext"
# pass=false → 告知用户原因,终止操作
# pass=true → 提取 media_type, content_type, file_size, file_name, file_ext
文件大小限制
| 类型 | media_type | 最大 |
|---|---|---|
| Excel/TXT/Xmind/Markdown | 5/13/14/7 | 10 MB |
| 图片 | 9 | 30 MB |
| PDF/Word/PPT/音频 | 1/3/4/15 等 | 200 MB |
上传流程
✅ 推荐方式:内联 Node.js 脚本(单步完成)
ima-knowledge-upload.cjs 内联执行 create_media → COS PUT → add_knowledge 全流程,
避免 secret_key 含 =+/ 等特殊字符时通过 shell 参数传递出现解析偏差。
# 用法
node <SCRIPT_PATH>/knowledge-base/scripts/ima-knowledge-upload.cjs \
--file "/path/to/file.pdf" \
--kb "<kb_id>" \
[--name "自定义标题(默认取文件名)"]
# 示例
node C:/Users/Administrator/.qclaw/skills/ima-knowledge/knowledge-base/scripts/ima-knowledge-upload.cjs \
--file "D:/研报/202401-华泰证券-宏观月报.pdf" \
--kb "KRCgTJmpYcgMGv3yl61DN6ARc6i1-RMk5przadKa_Ik="
脚本自动完成:凭证获取、文件类型推断、create_media、COS 签名上传、add_knowledge。
支持格式:.pdf .doc/.docx .ppt/.pptx .xls/.xlsx/.csv .md .png/.jpg/.jpeg/.webp .txt .mp3/.m4a/.wav。
高级:分步 bash 流程(供参考)
# 1. create_media — 获取 media_id 和 COS 上传凭证
ima_api "openapi/wiki/v1/create_media" "{
\"file_name\": \"<filename>\",
\"file_size\": <size_bytes>,
\"content_type\": \"<mime_type>\",
\"knowledge_base_id\": \"<kb_id>\",
\"file_ext\": \"<ext>\"
}"
# 提取: media_id, cos_credential{secret_id, secret_key, token, bucket_name, region, cos_key, start_time, expired_time}
# 2. 上传文件到 COS(注意 secret_key 含特殊字符时的转义问题)
node <SCRIPT_PATH>/knowledge-base/scripts/cos-upload.cjs \
--file "/path/to/file.ext" \
--secret-id "<secret_id>" \
--secret-key "<secret_key>" \
--token "<token>" \
--bucket "<bucket_name>" \
--region "<region>" \
--cos-key "<cos_key>" \
--content-type "<mime_type>" \
--start-time <start_time> \
--expired-time <expired_time>
# 3. add_knowledge — 关联到知识库
ima_api "openapi/wiki/v1/add_knowledge" "{
\"media_type\": <media_type>,
\"media_id\": \"<media_id>\",
\"title\": \"<filename>\",
\"knowledge_base_id\": \"<kb_id>\",
\"folder_id\": \"<folder_id>\",
\"file_info\": {
\"cos_key\": \"<cos_key>\",
\"file_size\": <size_bytes>,
\"file_name\": \"<filename>\"
}
}"
批量上传(目录扫描或文件列表)
ima-knowledge-batch-upload.cjs 复用 ima-knowledge-upload.cjs 逐文件上传,自动收集文件、过滤类型、汇总结果。
# 方式一:扫描整个目录
node <SCRIPT_PATH>/knowledge-base/scripts/ima-knowledge-batch-upload.cjs \
--dir "/path/to/reports" \
--kb "<kb_id>" \
[--recursive] \
[--pattern "pdf,docx"]
# 方式二:指定文件列表(逗号分隔)
node <SCRIPT_PATH>/knowledge-base/scripts/ima-knowledge-batch-upload.cjs \
--files "/path/a.pdf,/path/b.docx,/path/c.xlsx" \
--kb "<kb_id>"
选项说明:
--dir <folder>:扫描目录,自动过滤支持的文件类型--files <paths>:逗号分隔的完整文件路径列表(与--dir二选一)--kb <kb_id>:目标知识库 ID(必填)--recursive:递归扫描子目录(仅--dir模式有效)--pattern <exts>:按扩展名过滤,如pdf,docx(仅--dir模式有效)
输出示例:
📦 ima-knowledge 批量上传工具
目标知识库: KRCgTJmpYcgMGv3y...
文件总数: 5
扫描目录: D:\\研报\\2024Q1
扩展名过滤: pdf
[1/5] ✅ 202401-华泰证券-宏观月报.pdf
[2/5] ✅ 202402-中信证券-策略周报.pdf
[3/5] ❌ 202403-某研报.pdf
COS upload failed (HTTP 403)
...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 上传汇总
成功: 4/5
失败: 1/5
❌ 失败文件:
• 202403-某研报.pdf
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
添加网页/微信文章
# 批量添加(1-10个URL),自动识别类型(普通网页/微信公众号)
ima_api "openapi/wiki/v1/import_urls" '{
"knowledge_base_id": "<kb_id>",
"folder_id": "<folder_id>",
"urls": ["https://example.com/article", "https://mp.weixin.qq.com/s/xxx"]
}'
# 返回: results{url: {ret_code, media_id}}
文件类型对应
| 扩展名 | media_type | content_type |
|---|---|---|
.pdf |
1 | application/pdf |
.doc/.docx |
3 | application/msword |
.ppt/.pptx |
4 | application/vnd.ms-powerpoint |
.xls/.xlsx/.csv |
5 | application/vnd.ms-excel |
.md |
7 | text/markdown |
.png/.jpg/.webp |
9 | image/* |
.txt |
13 | text/plain |
.mp3/.m4a/.wav |
15 | audio/* |
不支持:.mp4/.avi/.mov 视频、Bilibili/YouTube 视频网页、file:// 本地 HTML。
响应格式
{ "retcode": 0, "errmsg": "...", "data": { ... } }
retcode=0:成功retcode≠0:失败,直接展示errmsg给用户
用户体验规范
- 不暴露内部 ID:展示知识库名称/文件标题,不展示
kb_id/media_id/folder_id - 隐藏内部步骤:上传文件时只说"已添加到知识库",不说"正在创建媒体…正在上传COS…"
- 批量汇总:"3 个文件已添加,1 个失败(data.xlsx: 文件大小超限)"
- 格式化展示:知识库列表、内容列表、搜索结果都要有结构化格式(见示例)
格式化示例
知识库列表:
📚 你的知识库(共3个):
1. **产品文档库** — 存放产品相关文档资料
2. **技术方案库**
3. **竞品分析库**
搜索结果:
🔍 在「产品文档库」中搜索「排期」:
1. 📄 Q1排期表.xlsx (文件夹: 项目管理/)
> ...包含**排期**计划的详细信息...
2. 📄 开发排期讨论.pdf
3. 📁 排期模板/ (根目录)
知识库内容:
📂 产品文档库内容:
📁 设计文档/ (3个文件, 1个子文件夹)
📁 会议纪要/ (12个文件)
📄 产品需求文档.pdf
--- 第1页,还有更多 ---Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 IMA 知识库完整的读写能力,覆盖搜索、浏览、上传文件、添加网页等高频刚需场景
- 支持批量上传和多种文件格式,显著提升知识库管理效率
Highlights
- 触发词覆盖全面且边界清晰,准确匹配知识库相关操作意图
Areas to improve
-
文档长度 Reported severity: Minor
主文档约 180 行,内容详尽但略显冗长
Recommendation: 建议增加目录导航或适当拆分章节以提升可读性
Highlights
- 结构完整,包含初始化、功能模块、上传流程、响应格式、用户体验规范等
- 提供详细的快速决策表和格式化展示示例
Highlights
- 工具来源明确,参数说明详细,覆盖主要异常场景
- 批量上传有汇总反馈,用户体验规范完善
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 29, 39 -
Administrator or elevated privileges
Elevate only when necessary. Keep protection and certificate validation enabled and avoid broad system access.
Mentioned in main document · lines 149
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- example.com
- ima.qq.com
- mp.weixin.qq.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
```bash
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.