feat: 修复【应用】-设置的调试预览提问经常出现 会话不存在的情况
This commit is contained in:
parent
618b32b8a7
commit
069e1c539f
@ -41,21 +41,18 @@ chat_cache = caches['chat_cache']
|
||||
class ChatInfo:
|
||||
def __init__(self,
|
||||
chat_id: str,
|
||||
chat_model: BaseChatModel | None,
|
||||
dataset_id_list: List[str],
|
||||
exclude_document_id_list: list[str],
|
||||
application: Application,
|
||||
work_flow_version: WorkFlowVersion = None):
|
||||
"""
|
||||
:param chat_id: 对话id
|
||||
:param chat_model: 对话模型
|
||||
:param dataset_id_list: 数据集列表
|
||||
:param exclude_document_id_list: 排除的文档
|
||||
:param application: 应用信息
|
||||
"""
|
||||
self.chat_id = chat_id
|
||||
self.application = application
|
||||
self.chat_model = chat_model
|
||||
self.dataset_id_list = dataset_id_list
|
||||
self.exclude_document_id_list = exclude_document_id_list
|
||||
self.chat_record_list: List[ChatRecord] = []
|
||||
@ -83,7 +80,6 @@ class ChatInfo:
|
||||
'dialogue_number': self.application.dialogue_number,
|
||||
'prompt': model_setting.get(
|
||||
'prompt') if 'prompt' in model_setting else Application.get_default_model_prompt(),
|
||||
'chat_model': self.chat_model,
|
||||
'model_id': model_id,
|
||||
'problem_optimization': self.application.problem_optimization,
|
||||
'stream': True,
|
||||
@ -282,7 +278,7 @@ class ChatMessageSerializer(serializers.Serializer):
|
||||
QuerySet(Document).filter(
|
||||
dataset_id__in=dataset_id_list,
|
||||
is_active=False)]
|
||||
return ChatInfo(chat_id, None, dataset_id_list, exclude_document_id_list, application)
|
||||
return ChatInfo(chat_id, dataset_id_list, exclude_document_id_list, application)
|
||||
|
||||
@staticmethod
|
||||
def re_open_chat_work_flow(chat_id, application):
|
||||
@ -290,4 +286,4 @@ class ChatMessageSerializer(serializers.Serializer):
|
||||
'-create_time')[0:1].first()
|
||||
if work_flow_version is None:
|
||||
raise AppApiException(500, "应用未发布,请发布后再使用")
|
||||
return ChatInfo(chat_id, None, [], [], application, work_flow_version)
|
||||
return ChatInfo(chat_id, [], [], application, work_flow_version)
|
||||
|
||||
@ -258,7 +258,7 @@ class ChatSerializers(serializers.Serializer):
|
||||
if work_flow_version is None:
|
||||
raise AppApiException(500, "应用未发布,请发布后再使用")
|
||||
chat_cache.set(chat_id,
|
||||
ChatInfo(chat_id, None, [],
|
||||
ChatInfo(chat_id, [],
|
||||
[],
|
||||
application, work_flow_version), timeout=60 * 30)
|
||||
return chat_id
|
||||
@ -271,7 +271,7 @@ class ChatSerializers(serializers.Serializer):
|
||||
application_id=application_id)]
|
||||
chat_id = str(uuid.uuid1())
|
||||
chat_cache.set(chat_id,
|
||||
ChatInfo(chat_id, None, dataset_id_list,
|
||||
ChatInfo(chat_id, dataset_id_list,
|
||||
[str(document.id) for document in
|
||||
QuerySet(Document).filter(
|
||||
dataset_id__in=dataset_id_list,
|
||||
@ -297,7 +297,7 @@ class ChatSerializers(serializers.Serializer):
|
||||
)
|
||||
work_flow_version = WorkFlowVersion(work_flow=work_flow)
|
||||
chat_cache.set(chat_id,
|
||||
ChatInfo(chat_id, None, [],
|
||||
ChatInfo(chat_id, [],
|
||||
[],
|
||||
application, work_flow_version), timeout=60 * 30)
|
||||
return chat_id
|
||||
@ -354,7 +354,7 @@ class ChatSerializers(serializers.Serializer):
|
||||
model_params_setting=self.data.get('model_params_setting'),
|
||||
user_id=user_id)
|
||||
chat_cache.set(chat_id,
|
||||
ChatInfo(chat_id, None, dataset_id_list,
|
||||
ChatInfo(chat_id, dataset_id_list,
|
||||
[str(document.id) for document in
|
||||
QuerySet(Document).filter(
|
||||
dataset_id__in=dataset_id_list,
|
||||
|
||||
@ -105,13 +105,8 @@ CACHES = {
|
||||
}
|
||||
},
|
||||
'chat_cache': {
|
||||
'BACKEND': 'common.cache.mem_cache.MemCache',
|
||||
'LOCATION': 'unique-snowflake',
|
||||
'TIMEOUT': 60 * 30,
|
||||
'OPTIONS': {
|
||||
'MAX_ENTRIES': 150,
|
||||
'CULL_FREQUENCY': 5,
|
||||
}
|
||||
'BACKEND': 'common.cache.file_cache.FileCache',
|
||||
'LOCATION': os.path.join(PROJECT_DIR, 'data', 'cache', "chat_cache") # 文件夹路径
|
||||
},
|
||||
# 存储用户信息
|
||||
'user_cache': {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user