Fix: add file convert backward compatibility (#14583)

### What problem does this PR solve?

add file convert backward compatibility

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
buua436
2026-05-06 15:19:38 +08:00
committed by GitHub
parent e8f19aa338
commit a190a6d67f
2 changed files with 22 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ Deprecated APIs and their replacements:
- POST /api/v1/chats_openai/{chat_id}/chat/completions -> POST /api/v1/openai/{chat_id}/chat/completions
- 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
- GET /api/v1/file/* -> GET /api/v1/files*
- POST /api/v1/file/* -> POST /api/v1/files*
- POST /api/v1/sessions/related_questions -> POST /api/v1/chat/recommandation
@@ -36,7 +37,7 @@ import logging
from quart import Blueprint, request
from api.apps import login_required
from api.apps.restful_apis import chat_api, file_api, chunk_api, openai_api, document_api
from api.apps.restful_apis import chat_api, file_api, file2document_api, chunk_api, openai_api, document_api
from api.apps.restful_apis import agent_api
from api.apps.services import file_api_service
from api.utils.api_utils import get_data_error_result, get_json_result, add_tenant_id_to_kwargs
@@ -240,6 +241,22 @@ async def deprecated_file_upload(tenant_id=None):
return await file_api.create_or_upload(tenant_id=tenant_id)
@manager.route("/file/convert", methods=["POST"])
@login_required
async def deprecated_file_convert():
"""
Deprecated: Use POST /api/v1/files/link-to-datasets instead.
Old path: POST /api/v1/file/convert
New path: POST /api/v1/files/link-to-datasets
"""
logging.warning(
"API endpoint /api/v1/file/convert is deprecated. "
"Please use POST /api/v1/files/link-to-datasets instead."
)
return await file2document_api.convert()
@manager.route("/file/mv", methods=["POST"])
@login_required
@add_tenant_id_to_kwargs

View File

@@ -7430,6 +7430,10 @@ or
```bash
curl --request POST \
--url http://{address}/api/v1/files/link-to-datasets \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--data '{
"file_ids": ["file_id_1", "file_id_2"],
"kb_ids": ["dataset_id_1", "dataset_id_2"]
}'
```