2023-11-16 05:16:27 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: chat_api.py
|
|
|
|
|
|
@date:2023/11/7 17:29
|
|
|
|
|
|
@desc:
|
|
|
|
|
|
"""
|
|
|
|
|
|
from drf_yasg import openapi
|
|
|
|
|
|
|
2024-01-16 08:46:54 +00:00
|
|
|
|
from application.swagger_api.application_api import ApplicationApi
|
2023-11-16 05:16:27 +00:00
|
|
|
|
from common.mixins.api_mixin import ApiMixin
|
2025-01-13 11:05:08 +00:00
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
2024-05-20 09:50:14 +00:00
|
|
|
|
class ChatClientHistoryApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID'))
|
2024-05-20 09:50:14 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
2025-02-24 10:53:21 +00:00
|
|
|
|
class Operate(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
|
|
|
|
|
description=_('Application ID')),
|
|
|
|
|
|
openapi.Parameter(name='chat_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
|
|
|
|
|
description=_('Conversation ID')),
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class ReAbstract(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['abstract'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'abstract': openapi.Schema(type=openapi.TYPE_STRING, title=_("abstract"),
|
|
|
|
|
|
description=_("abstract"))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-05-20 09:50:14 +00:00
|
|
|
|
|
2024-09-09 06:47:25 +00:00
|
|
|
|
class OpenAIChatApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['message'],
|
|
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'messages': openapi.Schema(type=openapi.TYPE_ARRAY, title=_("problem"),
|
|
|
|
|
|
description=_("problem"),
|
2024-09-09 06:47:25 +00:00
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['role', 'content'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'content': openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
title=_("Question content"),
|
|
|
|
|
|
default=''),
|
2024-09-09 06:47:25 +00:00
|
|
|
|
'role': openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
title=_('role'),
|
|
|
|
|
|
default="user")
|
2024-09-09 06:47:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
)),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'chat_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Conversation ID")),
|
|
|
|
|
|
're_chat': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("regenerate"),
|
|
|
|
|
|
default=False),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'stream': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Stream Output"),
|
|
|
|
|
|
default=True)
|
2024-09-09 06:47:25 +00:00
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
class ChatApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['message'],
|
|
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'message': openapi.Schema(type=openapi.TYPE_STRING, title=_("problem"), description=_("problem")),
|
|
|
|
|
|
're_chat': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("regenerate"), default=False),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'stream': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Is it streaming output"), default=True),
|
|
|
|
|
|
|
|
|
|
|
|
'form_data': openapi.Schema(type=openapi.TYPE_OBJECT, title=_("Form data"),
|
|
|
|
|
|
description=_("Form data"),
|
|
|
|
|
|
default={}),
|
|
|
|
|
|
'image_list': openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_ARRAY,
|
|
|
|
|
|
title=_("Image list"),
|
|
|
|
|
|
description=_("Image list"),
|
|
|
|
|
|
items=openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'name': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Image name")),
|
|
|
|
|
|
'url': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Image URL")),
|
|
|
|
|
|
'file_id': openapi.Schema(type=openapi.TYPE_STRING),
|
|
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
default=[]
|
|
|
|
|
|
),
|
|
|
|
|
|
'document_list': openapi.Schema(type=openapi.TYPE_ARRAY, title=_("Document list"),
|
|
|
|
|
|
description=_("Document list"),
|
|
|
|
|
|
items=openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
properties={
|
|
|
|
|
|
# 定义对象的具体属性
|
|
|
|
|
|
'name': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Document name")),
|
|
|
|
|
|
'url': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Document URL")),
|
|
|
|
|
|
'file_id': openapi.Schema(type=openapi.TYPE_STRING),
|
|
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
default=[]),
|
|
|
|
|
|
'audio_list': openapi.Schema(type=openapi.TYPE_ARRAY, title=_("Audio list"),
|
|
|
|
|
|
description=_("Audio list"),
|
|
|
|
|
|
items=openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'name': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Audio name")),
|
|
|
|
|
|
'url': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Audio URL")),
|
|
|
|
|
|
'file_id': openapi.Schema(type=openapi.TYPE_STRING),
|
|
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
default=[]),
|
|
|
|
|
|
'runtime_node_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Runtime node id"),
|
|
|
|
|
|
description=_("Runtime node id"),
|
|
|
|
|
|
default=""),
|
|
|
|
|
|
'node_data': openapi.Schema(type=openapi.TYPE_OBJECT, title=_("Node data"),
|
|
|
|
|
|
description=_("Node data"),
|
|
|
|
|
|
default={}),
|
|
|
|
|
|
'chat_record_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Conversation record id"),
|
|
|
|
|
|
description=_("Conversation record id"),
|
|
|
|
|
|
default=""),
|
|
|
|
|
|
'child_node': openapi.Schema(type=openapi.TYPE_STRING, title=_("Child node"),
|
|
|
|
|
|
description=_("Child node"),
|
|
|
|
|
|
default={}),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-12-21 10:31:58 +00:00
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['id', 'application', 'abstract', 'chat_record_count', 'mark_sum', 'star_num', 'trample_num',
|
|
|
|
|
|
'update_time', 'create_time'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
|
|
|
|
|
description="id", default="xx"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'application_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Application ID"),
|
|
|
|
|
|
description=_("Application ID"), default=_('Application ID')),
|
|
|
|
|
|
'abstract': openapi.Schema(type=openapi.TYPE_STRING, title=_("abstract"),
|
|
|
|
|
|
description=_("abstract"), default=_('abstract')),
|
|
|
|
|
|
'chat_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Conversation ID"),
|
|
|
|
|
|
description=_("Conversation ID"), default=_("Conversation ID")),
|
|
|
|
|
|
'chat_record_count': openapi.Schema(type=openapi.TYPE_STRING, title=_("Number of dialogue questions"),
|
|
|
|
|
|
description=_("Number of dialogue questions"),
|
|
|
|
|
|
default=0),
|
|
|
|
|
|
'mark_sum': openapi.Schema(type=openapi.TYPE_STRING, title=_("Number of tags"),
|
|
|
|
|
|
description=_("Number of tags"), default=1),
|
|
|
|
|
|
'star_num': openapi.Schema(type=openapi.TYPE_STRING, title=_("Number of likes"),
|
|
|
|
|
|
description=_("Number of likes"), default=1),
|
|
|
|
|
|
'trample_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of clicks"),
|
|
|
|
|
|
description=_("Number of clicks"), default=1),
|
|
|
|
|
|
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Change time"),
|
|
|
|
|
|
description=_("Change time"),
|
2023-12-21 10:31:58 +00:00
|
|
|
|
default="1970-01-01 00:00:00"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'create_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Creation time"),
|
|
|
|
|
|
description=_("Creation time"),
|
2023-12-21 10:31:58 +00:00
|
|
|
|
default="1970-01-01 00:00:00"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
class OpenChat(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2024-07-01 01:45:59 +00:00
|
|
|
|
class OpenWorkFlowTemp(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=[],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'work_flow': ApplicationApi.WorkFlow.get_request_body_api()
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
class OpenTempChat(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
2024-01-16 08:46:54 +00:00
|
|
|
|
required=['model_id', 'multiple_rounds_dialogue', 'dataset_setting', 'model_setting',
|
|
|
|
|
|
'problem_optimization'],
|
2023-11-16 05:16:27 +00:00
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Application ID"),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
description=_(
|
|
|
|
|
|
"Application ID, pass when modifying, do not pass when creating")),
|
|
|
|
|
|
'model_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Model ID"),
|
|
|
|
|
|
description=_("Model ID")),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
'dataset_id_list': openapi.Schema(type=openapi.TYPE_ARRAY,
|
|
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
title=_("List of associated knowledge base IDs"),
|
|
|
|
|
|
description=_("List of associated knowledge base IDs")),
|
|
|
|
|
|
'multiple_rounds_dialogue': openapi.Schema(type=openapi.TYPE_BOOLEAN,
|
|
|
|
|
|
title=_("Do you want to initiate multiple sessions"),
|
|
|
|
|
|
description=_(
|
|
|
|
|
|
"Do you want to initiate multiple sessions")),
|
2024-01-16 08:46:54 +00:00
|
|
|
|
'dataset_setting': ApplicationApi.DatasetSetting.get_request_body_api(),
|
|
|
|
|
|
'model_setting': ApplicationApi.ModelSetting.get_request_body_api(),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'problem_optimization': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Problem optimization"),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
description=_("Do you want to enable problem optimization"),
|
|
|
|
|
|
default=True)
|
2023-11-16 05:16:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='history_day',
|
|
|
|
|
|
in_=openapi.IN_QUERY,
|
|
|
|
|
|
type=openapi.TYPE_NUMBER,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Historical days')),
|
2023-12-06 08:29:14 +00:00
|
|
|
|
openapi.Parameter(name='abstract', in_=openapi.IN_QUERY, type=openapi.TYPE_STRING, required=False,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("abstract")),
|
2024-01-25 11:19:46 +00:00
|
|
|
|
openapi.Parameter(name='min_star', in_=openapi.IN_QUERY, type=openapi.TYPE_INTEGER, required=False,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("Minimum number of likes")),
|
2024-01-25 11:19:46 +00:00
|
|
|
|
openapi.Parameter(name='min_trample', in_=openapi.IN_QUERY, type=openapi.TYPE_INTEGER, required=False,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("Minimum number of clicks")),
|
2024-01-25 11:19:46 +00:00
|
|
|
|
openapi.Parameter(name='comparer', in_=openapi.IN_QUERY, type=openapi.TYPE_STRING, required=False,
|
2025-02-17 10:38:49 +00:00
|
|
|
|
description=_("or|and comparator")),
|
|
|
|
|
|
openapi.Parameter(name='start_time', in_=openapi.IN_QUERY,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
|
|
|
|
|
description=_('start time')),
|
|
|
|
|
|
openapi.Parameter(name='end_time', in_=openapi.IN_QUERY,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
|
|
|
|
|
description=_('End time')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChatRecordApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='chat_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
2023-12-21 10:31:58 +00:00
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['id', 'chat', 'vote_status', 'dataset', 'paragraph', 'source_id', 'source_type',
|
|
|
|
|
|
'message_tokens', 'answer_tokens',
|
|
|
|
|
|
'problem_text', 'answer_text', 'improve_paragraph_id_list'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
|
|
|
|
|
description="id", default="xx"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'chat': openapi.Schema(type=openapi.TYPE_STRING, title=_("Session log id"),
|
|
|
|
|
|
description=_("Conversation log id"), default=_('Conversation log id')),
|
|
|
|
|
|
'vote_status': openapi.Schema(type=openapi.TYPE_STRING, title=_("Voting Status"),
|
|
|
|
|
|
description=_("Voting Status"), default=_("Voting Status")),
|
|
|
|
|
|
'dataset': openapi.Schema(type=openapi.TYPE_STRING, title=_("Dataset id"), description=_("Dataset id"),
|
|
|
|
|
|
default=_("Dataset id")),
|
|
|
|
|
|
'paragraph': openapi.Schema(type=openapi.TYPE_STRING, title=_("Paragraph id"),
|
|
|
|
|
|
description=_("Paragraph id"), default=1),
|
|
|
|
|
|
'source_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Resource ID"),
|
|
|
|
|
|
description=_("Resource ID"), default=1),
|
|
|
|
|
|
'source_type': openapi.Schema(type=openapi.TYPE_STRING, title=_("Resource Type"),
|
|
|
|
|
|
description=_("Resource Type"), default='xxx'),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'message_tokens': openapi.Schema(type=openapi.TYPE_INTEGER,
|
|
|
|
|
|
title=_("Number of tokens consumed by the question"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("Number of tokens consumed by the question"), default=0),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'answer_tokens': openapi.Schema(type=openapi.TYPE_INTEGER,
|
|
|
|
|
|
title=_("The number of tokens consumed by the answer"),
|
|
|
|
|
|
description=_("The number of tokens consumed by the answer"),
|
|
|
|
|
|
default=0),
|
|
|
|
|
|
'improve_paragraph_id_list': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Improved annotation list"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("Improved annotation list"),
|
2023-12-21 10:31:58 +00:00
|
|
|
|
default=[]),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'index': openapi.Schema(type=openapi.TYPE_STRING,
|
|
|
|
|
|
title=_("Corresponding session Corresponding subscript"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_("Corresponding session id corresponding subscript"),
|
|
|
|
|
|
default=0
|
2023-12-21 10:31:58 +00:00
|
|
|
|
),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Modification time"),
|
|
|
|
|
|
description=_("Modification time"),
|
2023-12-21 10:31:58 +00:00
|
|
|
|
default="1970-01-01 00:00:00"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'create_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Creation time"),
|
|
|
|
|
|
description=_("Creation time"),
|
2023-12-21 10:31:58 +00:00
|
|
|
|
default="1970-01-01 00:00:00"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
class ImproveApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='chat_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='chat_record_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation record id')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Knowledge base id')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='document_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Document id')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['content'],
|
|
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING, title=_("Section title"),
|
|
|
|
|
|
description=_("Section title")),
|
|
|
|
|
|
'content': openapi.Schema(type=openapi.TYPE_STRING, title=_("Paragraph content"),
|
|
|
|
|
|
description=_("Paragraph content"))
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-11-12 09:49:22 +00:00
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api_post():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['dataset_id', 'document_id', 'chat_ids'],
|
|
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Knowledge base id"),
|
|
|
|
|
|
description=_("Knowledge base id")),
|
|
|
|
|
|
'document_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Document id"),
|
|
|
|
|
|
description=_("Document id")),
|
|
|
|
|
|
'chat_ids': openapi.Schema(type=openapi.TYPE_ARRAY, title=_("Conversation id list"),
|
|
|
|
|
|
description=_("Conversation id list"),
|
2024-11-12 09:49:22 +00:00
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api_post():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2024-11-12 09:49:22 +00:00
|
|
|
|
openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Knowledge base id')),
|
2024-11-12 09:49:22 +00:00
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
class VoteApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='chat_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation ID')),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
openapi.Parameter(name='chat_record_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation record id'))
|
2023-11-16 05:16:27 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['vote_status'],
|
|
|
|
|
|
properties={
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'vote_status': openapi.Schema(type=openapi.TYPE_STRING, title=_("Voting Status"),
|
|
|
|
|
|
description=_("-1: Cancel vote | 0: Agree | 1: Oppose")),
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2023-12-13 09:14:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChatRecordImproveApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return [openapi.Parameter(name='application_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Application ID')),
|
2023-12-13 09:14:43 +00:00
|
|
|
|
openapi.Parameter(name='chat_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation ID')),
|
2023-12-13 09:14:43 +00:00
|
|
|
|
openapi.Parameter(name='chat_record_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Conversation record id'))
|
2023-12-13 09:14:43 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['id', 'content', 'hit_num', 'star_num', 'trample_num', 'is_active', 'dataset_id',
|
|
|
|
|
|
'document_id', 'title',
|
|
|
|
|
|
'create_time', 'update_time'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
|
|
|
|
|
description="id", default="xx"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'content': openapi.Schema(type=openapi.TYPE_STRING, title=_("Paragraph content"),
|
|
|
|
|
|
description=_("Paragraph content"), default=_('Paragraph content')),
|
|
|
|
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING, title=_("title"),
|
|
|
|
|
|
description=_("title"), default=_("Description of xxx")),
|
2025-02-18 03:13:06 +00:00
|
|
|
|
'hit_num': openapi.Schema(type=openapi.TYPE_INTEGER, title=_("Number of hits"),
|
|
|
|
|
|
description=_("Number of hits"),
|
2023-12-13 09:14:43 +00:00
|
|
|
|
default=1),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'star_num': openapi.Schema(type=openapi.TYPE_INTEGER, title=_("Number of Likes"),
|
|
|
|
|
|
description=_("Number of Likes"), default=1),
|
|
|
|
|
|
'trample_num': openapi.Schema(type=openapi.TYPE_INTEGER, title=_("Number of thumbs-downs"),
|
|
|
|
|
|
description=_("Number of thumbs-downs"), default=1),
|
|
|
|
|
|
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Knowledge base id"),
|
|
|
|
|
|
description=_("Knowledge base id"), default='xxx'),
|
|
|
|
|
|
'document_id': openapi.Schema(type=openapi.TYPE_STRING, title=_("Document id"),
|
|
|
|
|
|
description=_("Document id"), default='xxx'),
|
|
|
|
|
|
'is_active': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Availability"),
|
|
|
|
|
|
description=_("Availability"), default=True),
|
|
|
|
|
|
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Modification time"),
|
|
|
|
|
|
description=_("Modification time"),
|
2023-12-13 09:14:43 +00:00
|
|
|
|
default="1970-01-01 00:00:00"),
|
2025-01-13 11:05:08 +00:00
|
|
|
|
'create_time': openapi.Schema(type=openapi.TYPE_STRING, title=_("Creation time"),
|
|
|
|
|
|
description=_("Creation time"),
|
2023-12-13 09:14:43 +00:00
|
|
|
|
default="1970-01-01 00:00:00"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|