diff --git a/api/apps/backward_compat.py b/api/apps/backward_compat.py index 3fa458bd35..5bd16f00fe 100644 --- a/api/apps/backward_compat.py +++ b/api/apps/backward_compat.py @@ -34,6 +34,7 @@ Deprecated APIs and their replacements: - PUT /api/v1/chats/{chat_id}/sessions/{session_id} -> PATCH /api/v1/chats/{chat_id}/sessions/{session_id} - DELETE /api/v1/chats -> DELETE /api/v1/chats/{chat_id} (with body) - POST /api/v1/file/convert -> POST /api/v1/files/link-to-datasets +- POST /v1/document/upload_info -> POST /api/v1/documents/upload - GET /api/v1/file/* -> GET /api/v1/files* - POST /api/v1/file/* -> POST /api/v1/files* - GET /api/v1/document/get/{doc_id} -> GET /api/v1/documents/{doc_id}/preview @@ -563,6 +564,25 @@ async def deprecated_file_upload_info(): return await document_api.upload_info(tenant_id=tenant_id) +@legacy_v1_manager.route("/document/upload_info", methods=["POST"]) +@login_required +async def deprecated_legacy_document_upload_info(): + """ + Deprecated: Use POST /api/v1/documents/upload instead. + + Old path: POST /v1/document/upload_info + New path: POST /api/v1/documents/upload + """ + from api.apps import current_user + + logging.warning( + "API endpoint /v1/document/upload_info is deprecated. " + "Please use POST /api/v1/documents/upload instead." + ) + tenant_id = current_user.id + return await document_api.upload_info(tenant_id=tenant_id) + + # ============================================================================= # Document APIs # ============================================================================= diff --git a/docs/references/http_api_reference.md b/docs/references/http_api_reference.md index abf18ab283..7d65c312e3 100644 --- a/docs/references/http_api_reference.md +++ b/docs/references/http_api_reference.md @@ -39,6 +39,7 @@ The following v0.24.0 REST API paths are deprecated. They remain available throu | **POST** `/api/v1/sessions/related_questions` | **POST** `/api/v1/chat/recommandation` | | **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}` | **PATCH** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}` | | **GET** `/v1/system/healthz` | **GET** `/api/v1/system/healthz` | +| **POST** `/v1/document/upload_info` | **POST** `/api/v1/documents/upload` | | **POST** `/api/v1/file/upload` | **POST** `/api/v1/files` | | **POST** `/api/v1/file/create` | **POST** `/api/v1/files` | | **GET** `/api/v1/file/list` | **GET** `/api/v1/files` | @@ -6928,14 +6929,18 @@ Failure: ### Upload document -**POST** `/v1/document/upload_info` +**POST** `/api/v1/documents/upload` Uploads a file and creates the respective document. +:::caution DEPRECATED +`POST /v1/document/upload_info` and `POST /api/v1/file/upload_info` are deprecated. Use this endpoint instead. +::: + #### Request - Method: POST -- URL: `/v1/document/upload_info` +- URL: `/api/v1/documents/upload` - Headers: - `'Content-Type: multipart/form-data'` - `'Authorization: Bearer '` @@ -6950,7 +6955,7 @@ Upload a local file: ```bash curl --request POST \ - --url http://{address}/v1/document/upload_info \ + --url http://{address}/api/v1/documents/upload \ --header 'Content-Type: multipart/form-data' \ --header 'Authorization: Bearer ' \ --form 'file=@./test1.pdf' @@ -6960,7 +6965,7 @@ Crawl a URL: ```bash curl --request POST \ - --url 'http://{address}/v1/document/upload_info?url=https://example.com/page' \ + --url 'http://{address}/api/v1/documents/upload?url=https://example.com/page' \ --header 'Authorization: Bearer ' ```