fix: Easy application import (#1930)
This commit is contained in:
parent
75a7630be8
commit
c6f821ce53
@ -170,7 +170,7 @@ class BaseChatStep(IChatStep):
|
|||||||
return iter(
|
return iter(
|
||||||
[AIMessageChunk(content=no_references_setting.get('value').replace('{question}', problem_text))]), False
|
[AIMessageChunk(content=no_references_setting.get('value').replace('{question}', problem_text))]), False
|
||||||
if chat_model is None:
|
if chat_model is None:
|
||||||
return iter([AIMessageChunk('抱歉,没有配置 AI 模型,无法优化引用分段,请先去应用中设置 AI 模型。')]), False
|
return iter([AIMessageChunk('抱歉,没有配置 AI 模型,请先去应用中设置 AI 模型。')]), False
|
||||||
else:
|
else:
|
||||||
return chat_model.stream(message_list), True
|
return chat_model.stream(message_list), True
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class BaseChatStep(IChatStep):
|
|||||||
'status') == 'designated_answer':
|
'status') == 'designated_answer':
|
||||||
return AIMessage(no_references_setting.get('value').replace('{question}', problem_text)), False
|
return AIMessage(no_references_setting.get('value').replace('{question}', problem_text)), False
|
||||||
if chat_model is None:
|
if chat_model is None:
|
||||||
return AIMessage('抱歉,没有配置 AI 模型,无法优化引用分段,请先去应用中设置 AI 模型。'), False
|
return AIMessage('抱歉,没有配置 AI 模型,请先去应用中设置 AI 模型。'), False
|
||||||
else:
|
else:
|
||||||
return chat_model.invoke(message_list), True
|
return chat_model.invoke(message_list), True
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,9 @@ class IResetProblemStep(IBaseChatPipelineStep):
|
|||||||
manage.context['problem_text'] = source_problem_text
|
manage.context['problem_text'] = source_problem_text
|
||||||
manage.context['padding_problem_text'] = padding_problem
|
manage.context['padding_problem_text'] = padding_problem
|
||||||
# 累加tokens
|
# 累加tokens
|
||||||
manage.context['message_tokens'] = manage.context['message_tokens'] + self.context.get('message_tokens')
|
manage.context['message_tokens'] = manage.context.get('message_tokens', 0) + self.context.get('message_tokens',
|
||||||
manage.context['answer_tokens'] = manage.context['answer_tokens'] + self.context.get('answer_tokens')
|
0)
|
||||||
|
manage.context['answer_tokens'] = manage.context.get('answer_tokens', 0) + self.context.get('answer_tokens', 0)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def execute(self, problem_text: str, history_chat_record: List[ChatRecord] = None, model_id: str = None,
|
def execute(self, problem_text: str, history_chat_record: List[ChatRecord] = None, model_id: str = None,
|
||||||
|
|||||||
@ -25,6 +25,8 @@ class BaseResetProblemStep(IResetProblemStep):
|
|||||||
user_id=None,
|
user_id=None,
|
||||||
**kwargs) -> str:
|
**kwargs) -> str:
|
||||||
chat_model = get_model_instance_by_model_user_id(model_id, user_id) if model_id is not None else None
|
chat_model = get_model_instance_by_model_user_id(model_id, user_id) if model_id is not None else None
|
||||||
|
if chat_model is None:
|
||||||
|
return problem_text
|
||||||
start_index = len(history_chat_record) - 3
|
start_index = len(history_chat_record) - 3
|
||||||
history_message = [[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()]
|
history_message = [[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()]
|
||||||
for index in
|
for index in
|
||||||
@ -57,8 +59,8 @@ class BaseResetProblemStep(IResetProblemStep):
|
|||||||
'step_type': 'problem_padding',
|
'step_type': 'problem_padding',
|
||||||
'run_time': self.context['run_time'],
|
'run_time': self.context['run_time'],
|
||||||
'model_id': str(manage.context['model_id']) if 'model_id' in manage.context else None,
|
'model_id': str(manage.context['model_id']) if 'model_id' in manage.context else None,
|
||||||
'message_tokens': self.context['message_tokens'],
|
'message_tokens': self.context.get('message_tokens', 0),
|
||||||
'answer_tokens': self.context['answer_tokens'],
|
'answer_tokens': self.context.get('answer_tokens', 0),
|
||||||
'cost': 0,
|
'cost': 0,
|
||||||
'padding_problem_text': self.context.get('padding_problem_text'),
|
'padding_problem_text': self.context.get('padding_problem_text'),
|
||||||
'problem_text': self.context.get("step_args").get('problem_text'),
|
'problem_text': self.context.get("step_args").get('problem_text'),
|
||||||
|
|||||||
@ -716,10 +716,11 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
desc=application.get('desc'),
|
desc=application.get('desc'),
|
||||||
prologue=application.get('prologue'), dialogue_number=application.get('dialogue_number'),
|
prologue=application.get('prologue'), dialogue_number=application.get('dialogue_number'),
|
||||||
dataset_setting=application.get('dataset_setting'),
|
dataset_setting=application.get('dataset_setting'),
|
||||||
|
model_setting=application.get('model_setting'),
|
||||||
model_params_setting=application.get('model_params_setting'),
|
model_params_setting=application.get('model_params_setting'),
|
||||||
tts_model_params_setting=application.get('tts_model_params_setting'),
|
tts_model_params_setting=application.get('tts_model_params_setting'),
|
||||||
problem_optimization=application.get('problem_optimization'),
|
problem_optimization=application.get('problem_optimization'),
|
||||||
icon=application.get('icon'),
|
icon="/ui/favicon.ico",
|
||||||
work_flow=work_flow,
|
work_flow=work_flow,
|
||||||
type=application.get('type'),
|
type=application.get('type'),
|
||||||
problem_optimization_prompt=application.get('problem_optimization_prompt'),
|
problem_optimization_prompt=application.get('problem_optimization_prompt'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user