最近更新时间:2024.04.17 14:21:08
首次发布时间:2024.04.17 14:21:08
/api/knowledge/collection/create 接口用于创建一个新的知识库。创建成功后,可以导入数据。
说明
完成“对接指南“页面的注册账号、实名认证、AK/SK 密钥获取和签名获取后,可调用 API 接口实现知识库的创建功能。
URI | http://api-knowledgebase.ml_platform.cn-beijing.volces.com/api/knowledge/collection/create | 统一资源标识符 |
---|---|---|
请求方法 | POST | 客户端对向量数据库服务器请求的操作类型 |
请求头 | Content-Type: application/json | 请求消息类型 |
Authorization: HMAC-SHA256 *** | 鉴权 |
参数 | 类型 | 是否必选 | 默认值 | 参数说明 |
---|---|---|---|---|
name | string | 是 | 知识库的名字。
| |
description | string | 否 | "" | 知识库描述信息。
|
preprocessing | object | 否 | { | |
index | object | 否 | { 注:
|
不同的向量化模型及其支持的索引类型组合,以及该组合的检索类型如下表:
向量化模型 | 产出类型 | 索引类型 | 检索类型 |
---|---|---|---|
bge-large-zh | 稠密向量 | hnsw、flat | 语义检索 |
bge-m3 | 稠密向量和稀疏向量 | hnsw_hybrid | 混合检索(兼顾语义检索和关键词匹配) |
hnsw、flat | 语义检索(此时稀疏向量被忽略,适用于只需要长文本窗口、多语言检索的纯语义检索场景) | ||
bge-large-zh-and-m3 | 稠密向量和稀疏向量 | hnsw_hybrid | 混合检索(兼顾语义检索和关键词匹配) |
参数 | 参数说明 |
---|---|
code | 状态码 |
message | 返回信息 |
request_id | 标识每个请求的唯一标识符 |
状态码 | http状态码 | 返回信息 | 状态码说明 |
---|---|---|---|
0 | 200 | success | 成功 |
1000001 | 403 | unauthorized | 鉴权失败 |
1000002 | 403 | no permission | 权限不足 |
1000003 | 400 | invalid request:%s | 非法参数
|
1000004 | 400 | collection exist | collection已存在 |
curl -i -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: HMAC-SHA256 ***' \ http://api-knowledgebase.ml_platform.cn-beijing.volces.com/api/knowledge/collection/create \ -d '{ "name": "test_collection_name", "description": "这是一个测试知识库", "preprocessing": { "chunk_length":500 } "index": { "index_type": "flat" "index_config": { "fields": [ { "field_name": "id", "field_type": "int64" }, { "field_name": "text", "field_type": "string", "default_val": "" } ] "cpu_quota": 2, "embedding_model": "bge-large-zh", "quant": "int8" } } }'
执行成功返回:
HTTP/1.1 200 OK Content-Length: 43 Content-Type: application/json {"code":0,"message":"success","request_id":"021695029537650fd001de666660000000000000000000230da93"}
执行失败返回:
HTTP/1.1 400 OK Content-Length: 43 Content-Type: application/json {"code":1000003, "message":"invalid request:%s", "request_id": "021695029757920fd001de6666600000000000000000002569b8f"}