新增知識區塊 (文字).md
新增知識區塊 (文字).md
將知識區塊新增至文字文件中。系統會依序執行分塊/切片、嵌入(embedding)/向量化,並最終將新知識區塊新增至文件中。
注意:系統使用預設的嵌入模型,無法透過 API 自行設定。
請求方法
POST
請求 URL
https://api-${endpoint}.gptbots.ai/v1/bot/doc/chunks/add
請求認證
請參閱概覽以瞭解認證細節。
請求
請求範例
curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/chunks/add' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "675174292b8b977ba6316191",
"chunks": [
{
"content": "This is a chunk.",
"keywords": ["This","chunk"]
}
]
}'
curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/chunks/add' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "675174292b8b977ba6316191",
"chunks": [
{
"content": "This is a chunk.",
"keywords": ["This","chunk"]
}
]
}'
此代碼塊在浮窗中顯示
請求標頭
| 欄位 | 類型 | 描述 |
|---|---|---|
| Authorization | Bearer ${API Key} | 使用 Authorization: Bearer ${API Key} 進行認證。API 金鑰可從 API Key 頁面取得。 |
| Content-Type | application/json | 資料類型,設為 application/json。 |
請求參數
| 欄位 | 類型 | 必填 | 描述 |
|---|---|---|---|
| doc_id | String | 是 | 要新增知識區塊的文件 ID。 |
| chunks | Array<Object> | 是 | 知識區塊的內容。 |
| content | String | 是 | 知識區塊的內容,最多 1000 Tokens 長度。 |
| keywords | Array<String> | 否 | 知識區塊的關鍵字。 |
回應
回應範例
{
"code": 0,
"message": "OK"
}
{
"code": 0,
"message": "OK"
}
此代碼塊在浮窗中顯示
成功回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| code | Int | 回應代碼。 |
| message | String | 回應詳情。 |
失敗回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| code | Int | 錯誤代碼。 |
| message | String | 錯誤詳情。 |
