fix: 修复ai对话节点输出内容回添加回车
This commit is contained in:
parent
cb97de66a8
commit
b19ed0d8db
@ -29,7 +29,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow):
|
|||||||
for key in step_variable:
|
for key in step_variable:
|
||||||
node.context[key] = step_variable[key]
|
node.context[key] = step_variable[key]
|
||||||
if workflow.is_result() and 'answer' in step_variable:
|
if workflow.is_result() and 'answer' in step_variable:
|
||||||
answer = step_variable['answer'] + '\n'
|
answer = step_variable['answer']
|
||||||
yield answer
|
yield answer
|
||||||
workflow.answer += answer
|
workflow.answer += answer
|
||||||
if global_variable is not None:
|
if global_variable is not None:
|
||||||
|
|||||||
@ -45,8 +45,6 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo
|
|||||||
for chunk in response:
|
for chunk in response:
|
||||||
answer += chunk.content
|
answer += chunk.content
|
||||||
yield chunk.content
|
yield chunk.content
|
||||||
answer += '\n'
|
|
||||||
yield '\n'
|
|
||||||
_write_context(node_variable, workflow_variable, node, workflow, answer)
|
_write_context(node_variable, workflow_variable, node, workflow, answer)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,6 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo
|
|||||||
for chunk in response:
|
for chunk in response:
|
||||||
answer += chunk.content
|
answer += chunk.content
|
||||||
yield chunk.content
|
yield chunk.content
|
||||||
answer += '\n'
|
|
||||||
yield '\n'
|
|
||||||
_write_context(node_variable, workflow_variable, node, workflow, answer)
|
_write_context(node_variable, workflow_variable, node, workflow, answer)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -209,9 +209,13 @@ class WorkflowManage:
|
|||||||
self.current_result = self.current_node.run()
|
self.current_result = self.current_node.run()
|
||||||
result = self.current_result.write_context(self.current_node, self)
|
result = self.current_result.write_context(self.current_node, self)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
for r in result:
|
if self.is_result():
|
||||||
if self.is_result():
|
for r in result:
|
||||||
yield self.get_chunk_content(r)
|
yield self.get_chunk_content(r)
|
||||||
|
yield self.get_chunk_content('\n')
|
||||||
|
self.answer += '\n'
|
||||||
|
else:
|
||||||
|
list(result)
|
||||||
if not self.has_next_node(self.current_result):
|
if not self.has_next_node(self.current_result):
|
||||||
yield self.get_chunk_content('', True)
|
yield self.get_chunk_content('', True)
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user