Skip to content

Commit 85e6760

Browse files
committed
feat: Support reasoning content(WIP)
1 parent 7c06134 commit 85e6760

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

apps/application/flow/i_step_node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def handler(self, chat_id,
6262
answer_tokens = sum([row.get('answer_tokens') for row in details.values() if
6363
'answer_tokens' in row and row.get('answer_tokens') is not None])
6464
answer_text_list = workflow.get_answer_text_list()
65-
answer_text = '\n\n'.join(answer['content'] for answer in answer_text_list)
65+
answer_text = '\n\n'.join(
66+
'\n\n'.join(["\n\n".join([a.get('reasoning_content'), a.get('content')]) for a in answer]) for answer in
67+
answer_text_list)
6668
if workflow.chat_record is not None:
6769
chat_record = workflow.chat_record
6870
chat_record.answer_text = answer_text

apps/application/flow/workflow_manage.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,20 +609,19 @@ def get_answer_text_list(self):
609609
if len(current_answer.content) > 0:
610610
if up_node is None or current_answer.view_type == 'single_view' or (
611611
current_answer.view_type == 'many_view' and up_node.view_type == 'single_view'):
612-
result.append(current_answer)
612+
result.append([current_answer])
613613
else:
614614
if len(result) > 0:
615615
exec_index = len(result) - 1
616-
content = result[exec_index].content
617-
result[exec_index].content += current_answer.content if len(
618-
content) == 0 else ('\n\n' + current_answer.content)
616+
if isinstance(result[exec_index], list):
617+
result[exec_index].append(current_answer)
619618
else:
620-
result.insert(0, current_answer)
619+
result.insert(0, [current_answer])
621620
up_node = current_answer
622621
if len(result) == 0:
623622
# 如果没有响应 就响应一个空数据
624-
return [Answer('', '', '', '', {}).to_dict()]
625-
return [r.to_dict() for r in result]
623+
return [[]]
624+
return [[item.to_dict() for item in r] for r in result]
626625

627626
def get_next_node(self):
628627
"""

ui/src/api/type/application.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,19 @@ export class ChatRecordManage {
290290
break
291291
}
292292
this.append_answer(
293-
(node_info.divider_content ? node_info.divider_content.splice(0).join('') : '') +
294-
node_info.current_node.buffer.splice(0).join(''),
295-
(node_info.divider_reasoning_content
296-
? node_info.divider_reasoning_content.splice(0).join('')
297-
: '') + node_info.current_node.reasoning_content_buffer.splice(0).join(''),
293+
node_info.current_node.buffer.splice(0).join(''),
294+
node_info.current_node.reasoning_content_buffer.splice(0).join(''),
298295
node_info.answer_text_list_index,
299296
node_info.current_node.chat_record_id,
300297
node_info.current_node.runtime_node_id,
301298
node_info.current_node.child_node,
302299
node_info.current_node.real_node_id
303300
)
304301

305-
if (node_info.current_node.buffer.length == 0) {
302+
if (
303+
node_info.current_node.buffer.length == 0 &&
304+
node_info.current_node.reasoning_content_buffer.length == 0
305+
) {
306306
node_info.current_node.is_end = true
307307
}
308308
}

0 commit comments

Comments
 (0)