通过服务端 API 调用,需配置 config.json 中的token(个人 API Token)。
list_collections / get_collection / 新建与修改文档等读写操作仅针对个人花园(source_type=garden);用户在灏天文库网页上的精品文集等非花园文集不会出现在列表中,也无法通过 ht-skills 操作。
--limit、--offset;仅返回当前用户的个人花园文集。
--collection-id(文集 ID);若没有文集 ID,需先 list_collections.py --name "文集名称" 查询,或向用户询问目标文集名称。
--limit、--offset。
author 字段不可更新,只能更新 name、content、sort、parent。
--from-collection-id。
file_url 可直接用于正文插图。
--group-id 前可用 list_image_groups.py 查询分组 ID;分组必须属于当前用户。
--collection-ids 须为灏天文库公开精品文集 ID(见下方公开目录链接);不要用 list_collections.py 查个人花园文集 ID 来做 RAG 检索。
list_documents.py --collection-id <文集ID> --name "关键词" 或 get_document.py --id 定位要修改的文档,确认文档 ID。
update_document.py --id 修改标题、正文。
list_collections.py --name "文集名称" 查询文集 ID;若不存在则询问是否新建。
add_document.py --collection-id --name "标题" [--content 内容] [--content-file 文件路径] 。
create_collection.py --name "文集名称"。若使用 --get-if-exists 则同名已存在时直接返回已有 ID,不重复创建。
list_documents.py --collection-id <文集ID> --name "关键词" 或 get_document.py --id 确认文档 ID。
list_collections.py --name "关键词" 查询。
move_document.py --id <文档ID> --collection-id <目标文集ID>;文档属于多个文集时需加 --from-collection-id <原文集ID>。
list_image_groups.py 或 create_image_group.py --name "分组名" 取得 group_id。
get_image_limits_usage.py 确认 can_upload。
upload_image.py --file "路径" [--remark "说明"] [--group-id N]。
data.file_url(或 data.file_path 自行拼域名)插入文档 Markdown/HTML;勿猜测 URL。
--content。
189 对应「AI 大模型」)。
list_collections.py:该接口只返回当前用户个人花园文集,与 RAG 索引的公开精品文集不是同一套数据。
```bash
python scripts/retrieve_documents.py --content "用户的问题" --collection-ids 189 907
```
sources 为相关片段及出处(文集名、文档名、source 字段等);本接口不调用大模型,由智能体根据片段自行组织回答或引用。若响应含 warning,说明传入文集超过 5 个,已自动截断。
get_garden_limits_usage.py,确认 usage.can_create_collection、目标文集的 documents_quota 及 limits.max_chars_per_document。
data.membership.is_member 为 true 表示当前为会员(member_status=1);实际配额上限仍以 data.limits 为准(由灏天文库计算,含等级 tier 与会员倍数)。
is_member 为 false 且某文集 documents_quota.used 已超过当前 limit,应告知用户「存量保留,但不能再新建/扩容」;更新超长正文可能因字数上限被 403 拒绝。
已用/上限(如 collections_quota.text、documents_quota.text),建议删减内容、更换文集或续费会员后再操作。
sys_collection_upload,由管理员在灏天文库「文集审核管理」审核。
check_garden_promotion_quota.py,确认 can_submit 为 true(每用户 24 小时最多 1 次)。
list_collections.py 或 get_collection.py;文集内应已有文档。
request_garden_promotion.py --collection-id [--reason "说明"] 。
list_my_garden_promotion_requests.py(status:0 待审、1 通过、2 驳回)。
config.json,填写token。
HT_SKILL_SERVER_URL、HT_SKILL_TOKEN 优先级高于 config.json。
pip install requests
所有脚本位于 scripts/,在 client 根目录执行。
python scripts/create_collection.py --name "文集名称" [--description "50字内简介"] [--brief "500字以上详细介绍"]
python scripts/create_collection.py --name "文集名称" --get-if-exists
python scripts/add_document.py --collection-id 123 --name "文档标题" [--content "正文"] [--content-file 路径] [--parent 0]
python scripts/list_collections.py [--name "关键词"]
python scripts/get_collection.py --id 123 [--include-docs]
python scripts/list_documents.py --collection-id 123 [--name "关键词"]
# collection-id 必填。若无文集 ID,需先 list_collections 查询或向用户询问
python scripts/get_document.py --id 456
python scripts/update_document.py --id 456 --name "新标题"
python scripts/update_document.py --id 456 --content "新正文"
python scripts/update_document.py --id 456 --content-file 文件路径
python scripts/update_document.py --id 456 --sort 50
python scripts/update_document.py --id 456 --parent 0
# 将文档移动到目标文集
python scripts/move_document.py --id 456 --collection-id 789
# 文档属于多个文集时,需指定原文集 ID
python scripts/move_document.py --id 456 --collection-id 789 --from-collection-id 123
--id:文档 ID(必填)
--collection-id:目标文集 ID(必填)
--from-collection-id:原文集 ID;文档只属于一个文集可不填,属于多个文集则必填
python scripts/set_document_parent.py --collection-id 123 --document-id 456 --parent 0 [--sort 1]
parent=0 表示根文档;同级别 sort 越小越靠前
python scripts/get_garden_limits_usage.py
source_type=garden 文集)
已用/上限 结构(如 3/10、18/100)
data.membership(is_member、member_status),便于向用户解释会员与配额;实际上限以 data.limits 为准
python scripts/create_image_group.py --name "分组名称"
python scripts/list_image_groups.py [--limit 100] [--offset 0]
python scripts/update_image_group.py --id <分组ID> --name "新名称"
python scripts/get_image_limits_usage.py
python scripts/upload_image.py --file "图片路径" [--remark "备注"] [--group-id N]
python scripts/list_images.py [--group-id N] [--name "文件名关键词"] [--limit 50] [--offset 0]
python scripts/get_image.py --id <图片ID>
data.file_url 为可访问地址(依赖服务端 cos.public_base_url 或 cos.domain 配置)
list_images.py 的 --name 对应服务端查询参数 file_name(文件名模糊匹配)
从灏天文库 RAG 向量索引中检索与问题相关的文档片段及出处,不调用大模型。
RAG 检索针对的是平台公开精品文集(已入库向量索引),ID 与名称对照见官方目录:
目录按领域分类(如「人工智能与大模型」「编程语言与开发框架」等),每行格式为 ID | 文集名称。执行检索时,将表格中的 ID 数字 作为 --collection-ids 传入即可(如 ID 189 可写 189 或 collection_189)。
> 注意:list_collections.py 只能查到当前用户自己的个人花园文集,不能替代上述公开目录;做 RAG 检索时请以上述链接为准。
# 在公开目录中查到「AI 大模型」ID 为 189、「人工智能基础」ID 为 907 后:
python scripts/retrieve_documents.py --content "什么是 Transformer?" --collection-ids 189 907
# ID 也可带 collection_ 前缀
python scripts/retrieve_documents.py --content "检索内容" --collection-ids collection_189
| 参数 | 必填 | 说明 |
|------|------|------|
| --content | 是 | 检索内容/用户问题 |
| --collection-ids | 是 | 文集 ID 列表,从公开目录获取;支持 21 或 collection_21;最多 5 个,超出仅使用前 5 个并返回 warning |
sources:命中的文档片段列表,含 content(片段)、document_name、collection_name、source(出处描述)、distance(相似度)等
collection_info:实际检索的文集、未建索引文集等汇总信息
sources 组织回答,并注明引用出处;勿编造目录中不存在的文集 ID
python scripts/check_garden_promotion_quota.py
python scripts/request_garden_promotion.py --collection-id <文集ID> [--reason "申请说明"]
python scripts/list_my_garden_promotion_requests.py [--limit 50] [--offset 0]
source_type=garden)
source_type=collection)
共 4 个版本