feat: add DocumentBatchCreateAPI for batch document creation
This commit is contained in:
parent
ee2ac7835c
commit
ba5028858c
@ -4,7 +4,7 @@ from drf_spectacular.utils import OpenApiParameter
|
|||||||
from common.mixins.api_mixin import APIMixin
|
from common.mixins.api_mixin import APIMixin
|
||||||
from common.result import DefaultResultSerializer
|
from common.result import DefaultResultSerializer
|
||||||
from knowledge.serializers.common import BatchSerializer
|
from knowledge.serializers.common import BatchSerializer
|
||||||
from knowledge.serializers.document import DocumentCreateRequest
|
from knowledge.serializers.document import DocumentCreateRequest, DocumentInstanceSerializer
|
||||||
|
|
||||||
|
|
||||||
class DocumentCreateAPI(APIMixin):
|
class DocumentCreateAPI(APIMixin):
|
||||||
@ -98,3 +98,32 @@ class DocumentBatchAPI(APIMixin):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_response():
|
def get_response():
|
||||||
return DefaultResultSerializer
|
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
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from common.auth import TokenAuth
|
|||||||
from common.auth.authentication import has_permissions
|
from common.auth.authentication import has_permissions
|
||||||
from common.constants.permission_constants import PermissionConstants
|
from common.constants.permission_constants import PermissionConstants
|
||||||
from common.result import result
|
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.api.knowledge import KnowledgeTreeReadAPI
|
||||||
from knowledge.serializers.document import DocumentSerializers
|
from knowledge.serializers.document import DocumentSerializers
|
||||||
from knowledge.serializers.knowledge import KnowledgeSerializer
|
from knowledge.serializers.knowledge import KnowledgeSerializer
|
||||||
@ -76,9 +76,9 @@ class DocumentView(APIView):
|
|||||||
methods=['POST'],
|
methods=['POST'],
|
||||||
description=_('Create documents in batches'),
|
description=_('Create documents in batches'),
|
||||||
operation_id=_('Create documents in batches'),
|
operation_id=_('Create documents in batches'),
|
||||||
request=DocumentBatchAPI.get_request(),
|
request=DocumentBatchCreateAPI.get_request(),
|
||||||
parameters=DocumentBatchAPI.get_parameters(),
|
parameters=DocumentBatchCreateAPI.get_parameters(),
|
||||||
responses=DocumentBatchAPI.get_response(),
|
responses=DocumentBatchCreateAPI.get_response(),
|
||||||
tags=[_('Knowledge Base/Documentation')]
|
tags=[_('Knowledge Base/Documentation')]
|
||||||
)
|
)
|
||||||
@has_permissions([
|
@has_permissions([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user