更新試算表文件 (檔案) - GPTBots
更新試算表文件 (檔案) - GPTBots
批次更新試算表類型文件。系統將依序執行分塊、嵌入,並以新文件內容替換舊文件內容,同時保持文件 ID 不變。
注意:
嵌入模型採用預設模型,無法於 API 內自訂。
僅回傳上傳結果,不含最終嵌入(向量化)結果。您可透過「查詢文件狀態」API 取得最終處理進度。
請求方法
PUT
請求 URL
https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update
請求認證
請參閱概覽,瞭解認證相關細節。
請求
請求範例
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "67457fea6f658672d6482542",
"chunk_token": 700,
"header_row": 5,
"files": [
{
"file_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
"source_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
"file_name": "spreadsheet_1.xlsx"
}
]
}'
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "67457fea6f658672d6482542",
"chunk_token": 700,
"header_row": 5,
"files": [
{
"file_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
"source_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
"file_name": "spreadsheet_1.xlsx"
}
]
}'
此代碼塊在浮窗中顯示
請求標頭
| 欄位 | 類型 | 描述 |
|---|---|---|
| Authorization | Bearer ${API Key} | 請以 Authorization: Bearer ${API Key} 進行認證。您可於 API Key 頁面取得 API 金鑰。 |
| Content-Type | application/json | 資料類型,固定值為 application/json。 |
請求參數
| 欄位 | 類型 | 必填 | 描述 |
|---|---|---|---|
| files | Array<Object> | 是 | 待更新文件清單。最多支援同時更新 20 個文件。 |
| doc_id | String | 是 | 欲更新文件的 ID。 |
| file_url | String | 否 | 檔案的URL,支援 csv/xls/xlsx 格式。單檔最大 10MB。請注意:URL 或 base64 必須擇一提供。若同時提供,系統將優先使用 base64。 |
| file_base64 | String | 否 | 檔案的 base64 編碼,支援 csv/xls/xlsx 格式。單檔最大 10MB。請注意:URL 或 base64 必須擇一提供。若同時提供,系統將優先使用 base64。 |
| source_url | String | 否 | 檔案來源網址,需符合 URL 格式規範。若未填寫,系統不會更新此欄位。若需將此值設為空,請輸入 NULL。 |
| chunk_token | Integer | 否 | 分塊時每個知識區塊的最大標記數(token)。預設值為 600,範圍為 1~1000。 |
| header_row | Integer | 否 | 試算表標題行數。系統將以「標題+資料行」進行分塊。預設值為 1,範圍 1~5。 |
回應
回應範例
{
"doc": [
{
"doc_id": "xxxxxx",
"doc_name": "test_1.csv"
},
{
"doc_id": "xxxxxx",
"doc_name": "test_2.xlsx"
}
],
"failed": [
"xxxxxx",
"xxxxxx"
]
}
{
"doc": [
{
"doc_id": "xxxxxx",
"doc_name": "test_1.csv"
},
{
"doc_id": "xxxxxx",
"doc_name": "test_2.xlsx"
}
],
"failed": [
"xxxxxx",
"xxxxxx"
]
}
此代碼塊在浮窗中顯示
成功回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| doc | Array<Object> | 已更新文件列表。 |
| doc_id | String | 已更新文件的 ID。 |
| doc_name | String | 已更新文件的名稱。 |
| failed | Array<String> | 更新失敗的文件 ID 清單。 |
失敗回應
| 欄位 | 類型 | 描述 |
|---|---|---|
| code | Int | 錯誤代碼。例如 400 表示參數錯誤、401 表示驗證失敗、500 為伺服器內部錯誤等。 |
| message | String | 錯誤詳情。包含失敗原因,如檔案格式不支援、參數缺失等情境。 |
