diff --git a/apps/knowledge/api/document.py b/apps/knowledge/api/document.py index b8dca50c4..4ec48e104 100644 --- a/apps/knowledge/api/document.py +++ b/apps/knowledge/api/document.py @@ -4,7 +4,7 @@ from drf_spectacular.utils import OpenApiParameter from common.mixins.api_mixin import APIMixin from common.result import DefaultResultSerializer from knowledge.serializers.common import BatchSerializer -from knowledge.serializers.document import DocumentCreateRequest +from knowledge.serializers.document import DocumentCreateRequest, DocumentInstanceSerializer class DocumentCreateAPI(APIMixin): @@ -98,3 +98,32 @@ class DocumentBatchAPI(APIMixin): @staticmethod def get_response(): return DefaultResultSerializer + + +class DocumentBatchCreateAPI(APIMixin): + @staticmethod + def get_parameters(): + return [ + OpenApiParameter( + name="workspace_id", + description="工作空间id", + type=OpenApiTypes.STR, + location='path', + required=True, + ), + OpenApiParameter( + name="knowledge_id", + description="知识库id", + type=OpenApiTypes.STR, + location='path', + required=True, + ), + ] + + @staticmethod + def get_request(): + return DocumentInstanceSerializer(many=True) + + @staticmethod + def get_response(): + return DefaultResultSerializer diff --git a/apps/knowledge/views/document.py b/apps/knowledge/views/document.py index 320d09bde..8b0b785d4 100644 --- a/apps/knowledge/views/document.py +++ b/apps/knowledge/views/document.py @@ -8,7 +8,7 @@ from common.auth import TokenAuth from common.auth.authentication import has_permissions from common.constants.permission_constants import PermissionConstants from common.result import result -from knowledge.api.document import DocumentSplitAPI, DocumentBatchAPI +from knowledge.api.document import DocumentSplitAPI, DocumentBatchAPI, DocumentBatchCreateAPI from knowledge.api.knowledge import KnowledgeTreeReadAPI from knowledge.serializers.document import DocumentSerializers from knowledge.serializers.knowledge import KnowledgeSerializer @@ -76,9 +76,9 @@ class DocumentView(APIView): methods=['POST'], description=_('Create documents in batches'), operation_id=_('Create documents in batches'), - request=DocumentBatchAPI.get_request(), - parameters=DocumentBatchAPI.get_parameters(), - responses=DocumentBatchAPI.get_response(), + request=DocumentBatchCreateAPI.get_request(), + parameters=DocumentBatchCreateAPI.get_parameters(), + responses=DocumentBatchCreateAPI.get_response(), tags=[_('Knowledge Base/Documentation')] ) @has_permissions([