更新文字文件
更新文字文件
批量更新文字型文件。系統將依序進行分塊或分段、嵌入(向量化),最後以新文件內容取代舊文件內容,文件 ID 維持不變。
注意:
嵌入模型採用預設模型,無法透過 API 自行設定。
僅回傳上傳結果,非最終向量化結果。您可透過「查詢文件狀態」API 取得最終處理結果。
請求方法
PUT
請求 URL
https://api-${endpoint}.gptbots.ai/v1/bot/doc/text/update
請求認證
請參考概述部分了解認證詳情。
請求
請求範例
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/text/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "67457fea6f658672d6482542",
"chunk_token": 600,
"splitter": "\n",
"files": [
{
"doc_id": "675158a5af12af632a4f63f6",
"file_url": "https://www.gptbots.ai/doc/article_1.pdf",
"source_url": "https://www.gptbots.ai/doc/article_1.pdf",
"file_name": "article_1.pdf"
}
]
}'
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/text/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "67457fea6f658672d6482542",
"chunk_token": 600,
"splitter": "\n",
"files": [
{
"doc_id": "675158a5af12af632a4f63f6",
"file_url": "https://www.gptbots.ai/doc/article_1.pdf",
"source_url": "https://www.gptbots.ai/doc/article_1.pdf",
"file_name": "article_1.pdf"
}
]
}'
此代碼塊在浮窗中顯示
請求標頭
| 欄位 | 類型 | 描述 |
|---|---|---|
| Authorization | Bearer ${API Key} | 使用 Authorization: Bearer ${API Key} 進行認證。API Key 可於 API Key 頁面取得。 |
| Content-Type | application/json | 資料類型,設為 application/json。 |
請求參數
| 欄位 | 類型 | 必填 | 描述 |
|---|---|---|---|
| files | Array<Object> | 是 | 要更新的文件清單。最多同時支援 200 筆。 |
| doc_id | String | 是 | 要更新的文件 ID。 |
| file_url | String | 否 | 要更新的文件 URL。支援格式:pdf/txt/md/doc/docx。PDF 最大 30MB,其餘格式最大 10MB。請注意:file_url 與 file_base64 必須擇一提供,若同時提供,以 base64 優先。 |
| file_base64 | String | 否 | 要更新的文件 base64。支援格式同上。PDF 最大 30MB,其餘格式最大 10MB。請注意:file_url 與 file_base64 必須擇一提供,若同時提供,以 base64 優先。 |
| source_url | String | 否 | 要更新的文件來源網址,需符合 URL 格式規範。若不填寫,系統不會更新此值。若需將此值設為空,請輸入 NULL(即字串 "NULL")。 |
| chunk_token | Integer | 否 | 分塊時每個知識塊的最大 token 數量,預設 600,範圍 1-1000。請注意:chunk_token 或 splitter 必須擇一提供,若同時提供,以 splitter 優先。 |
| splitter | String | 否 | 分塊時使用的分隔符(例如換行符 "\n"),預設為空。請注意:chunk_token 或 splitter 必須擇一提供,若同時提供,以 splitter 優先。 |
回應
回應範例
{
"doc": [
{
"doc_id": "xxxxxx",
"doc_name": "test_1.txt"
},
{
"doc_id": "xxxxxx",
"doc_name": "test_2.pdf"
}
],
"failed": [
"xxxxxx",
"xxxxxx"
]
}
{
"doc": [
{
"doc_id": "xxxxxx",
"doc_name": "test_1.txt"
},
{
"doc_id": "xxxxxx",
"doc_name": "test_2.pdf"
}
],
"failed": [
"xxxxxx",
"xxxxxx"
]
}
此代碼塊在浮窗中顯示
成功回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| doc | Array<Object> | 已更新的文件清單。 |
| doc_id | String | 已更新的文件 ID。 |
| doc_name | String | 已更新的文件名稱。 |
| failed | Array<Object> | 更新失敗的文件 ID 清單。 |
失敗回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| code | Int | 錯誤代碼。 |
| message | String | 錯誤詳情。 |
