知识库管理

接口说明

接口鉴权方式: 在控制台创建apikey,将apikey放入每个请求头的Authorization字段中完成鉴权。

创建一个知识库

创建知识库,获取知识库id。

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/create_kb' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbName": "知识库1"
}'

删除知识库

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/delete_kb' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB248e8e079642491383596f63c2ab069a_240430"
}'

上传文档(文件)

为知识库添加文档

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/upload_file' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"C:\\Users\\user\\Desktop\\qanything测试文件\\test.pdf"' \
--form 'kbId="KBa3d4f06881484a97a1c78d058ec92869_240430"' \

上传文档连接(url)

为知识库添加文档

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/upload_url' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB248e8e079642491383596f63c2ab069a_240430",
    "url": "https://upimg.baike.so.com/doc/3361515-3539268.html"
}'

删除文档

删除知识库中的文档

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/delete_file' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB248e8e079642491383596f63c2ab069a_240430",
    "fileIds": ["6daacc4d4b1e4fe0a42db925f59ccc4f"]
}'

查询知识库列表

获取所有知识库列表

请求示例响应示例

shell

curl --location --request GET 'https://openapi.youdao.com/q_anything/api/kb_list' \
--header 'Authorization: {{apikey}}' \

查询知识库文档列表

查询知识库文档列表

请求示例参数说明响应示例

shell

curl --location --request GET 'https://openapi.youdao.com/q_anything/api/file_list?kbId=KB0f2cf0ae51684a9ca44b1af6cc091eed_240430' \
--header 'Authorization: {{apikey}}' \

修改知识库名称

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/kb_config' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB248e8e079642491383596f63c2ab069a_240430",
    "kbName": "知识库2"
}'

创建问答集

为知识库创建问答集

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/upload_faq' \
--header 'Content-Type: multipart/form-data' \
--form 'kbId="KBa3d4f06881484a97a1c78d058ec92869_240430"' \
--form 'question="你好"' \
--form 'answer="你好呀"' \

更新问答集

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/update_faq' \
--header 'Content-Type: multipart/form-data' \
--form 'kbId="KBa3d4f06881484a97a1c78d058ec92869_240430"' \
--form 'faqId="5df397aa27f544b4a156136011a2e34c"' \
--form 'question="你好吗"' \
--form 'answer="我很好"' \

删除问答集

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/delete_faq' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB248e8e079642491383596f63c2ab069a_240430",
    "faqIds": ["5df397aa27f544b4a156136011a2e34c"]
}'

查询问答集列表

请求示例参数说明响应示例

shell

curl --location --request GET 'https://openapi.youdao.com/q_anything/api/faq_list?kbId={{kbId}}' \
--header 'Authorization:  {{apikey}}' \

查询 faq 详情

请求示例参数说明响应示例

shell

curl --location --request POST 'https://openapi.youdao.com/q_anything/api/faqDetail' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "kbId": "KB8d21ee7e280b438d81dea9997b743a31_240xxx",
    "faqId": "aef2d9f5fc3540f7a06a1b67f6f79xxx"
}'