Skip to content

Commit c6f821c

Browse files
authored
fix: Easy application import (#1930)
1 parent 75a7630 commit c6f821c

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def get_stream_result(message_list: List[BaseMessage],
170170
return iter(
171171
[AIMessageChunk(content=no_references_setting.get('value').replace('{question}', problem_text))]), False
172172
if chat_model is None:
173-
return iter([AIMessageChunk('抱歉,没有配置 AI 模型,无法优化引用分段,请先去应用中设置 AI 模型。')]), False
173+
return iter([AIMessageChunk('抱歉,没有配置 AI 模型,请先去应用中设置 AI 模型。')]), False
174174
else:
175175
return chat_model.stream(message_list), True
176176

@@ -214,7 +214,7 @@ def get_block_result(message_list: List[BaseMessage],
214214
'status') == 'designated_answer':
215215
return AIMessage(no_references_setting.get('value').replace('{question}', problem_text)), False
216216
if chat_model is None:
217-
return AIMessage('抱歉,没有配置 AI 模型,无法优化引用分段,请先去应用中设置 AI 模型。'), False
217+
return AIMessage('抱歉,没有配置 AI 模型,请先去应用中设置 AI 模型。'), False
218218
else:
219219
return chat_model.invoke(message_list), True
220220

apps/application/chat_pipeline/step/reset_problem_step/i_reset_problem_step.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ def _run(self, manage: PipelineManage):
4545
manage.context['problem_text'] = source_problem_text
4646
manage.context['padding_problem_text'] = padding_problem
4747
# 累加tokens
48-
manage.context['message_tokens'] = manage.context['message_tokens'] + self.context.get('message_tokens')
49-
manage.context['answer_tokens'] = manage.context['answer_tokens'] + self.context.get('answer_tokens')
48+
manage.context['message_tokens'] = manage.context.get('message_tokens', 0) + self.context.get('message_tokens',
49+
0)
50+
manage.context['answer_tokens'] = manage.context.get('answer_tokens', 0) + self.context.get('answer_tokens', 0)
5051

5152
@abstractmethod
5253
def execute(self, problem_text: str, history_chat_record: List[ChatRecord] = None, model_id: str = None,

apps/application/chat_pipeline/step/reset_problem_step/impl/base_reset_problem_step.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def execute(self, problem_text: str, history_chat_record: List[ChatRecord] = Non
2525
user_id=None,
2626
**kwargs) -> str:
2727
chat_model = get_model_instance_by_model_user_id(model_id, user_id) if model_id is not None else None
28+
if chat_model is None:
29+
return problem_text
2830
start_index = len(history_chat_record) - 3
2931
history_message = [[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()]
3032
for index in
@@ -57,8 +59,8 @@ def get_details(self, manage, **kwargs):
5759
'step_type': 'problem_padding',
5860
'run_time': self.context['run_time'],
5961
'model_id': str(manage.context['model_id']) if 'model_id' in manage.context else None,
60-
'message_tokens': self.context['message_tokens'],
61-
'answer_tokens': self.context['answer_tokens'],
62+
'message_tokens': self.context.get('message_tokens', 0),
63+
'answer_tokens': self.context.get('answer_tokens', 0),
6264
'cost': 0,
6365
'padding_problem_text': self.context.get('padding_problem_text'),
6466
'problem_text': self.context.get("step_args").get('problem_text'),

apps/application/serializers/application_serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,11 @@ def to_application(application, user_id):
716716
desc=application.get('desc'),
717717
prologue=application.get('prologue'), dialogue_number=application.get('dialogue_number'),
718718
dataset_setting=application.get('dataset_setting'),
719+
model_setting=application.get('model_setting'),
719720
model_params_setting=application.get('model_params_setting'),
720721
tts_model_params_setting=application.get('tts_model_params_setting'),
721722
problem_optimization=application.get('problem_optimization'),
722-
icon=application.get('icon'),
723+
icon="/ui/favicon.ico",
723724
work_flow=work_flow,
724725
type=application.get('type'),
725726
problem_optimization_prompt=application.get('problem_optimization_prompt'),

0 commit comments

Comments
 (0)