Browse Source

fix: iteration total tokens calculate error (#15813)

Co-authored-by: 刘江波 <jiangbo721@163.com>
tags/1.1.0
jiangbo721 7 months ago
parent
commit
5646442931
No account linked to committer's email address

+ 2
- 1
api/core/workflow/graph_engine/graph_engine.py View File

def create_copy(self): def create_copy(self):
""" """
create a graph engine copy create a graph engine copy
:return: with a new variable pool instance of graph engine
:return: graph engine with a new variable pool and initialized total tokens
""" """
new_instance = copy(self) new_instance = copy(self)
new_instance.graph_runtime_state = copy(self.graph_runtime_state) new_instance.graph_runtime_state = copy(self.graph_runtime_state)
new_instance.graph_runtime_state.variable_pool = deepcopy(self.graph_runtime_state.variable_pool) new_instance.graph_runtime_state.variable_pool = deepcopy(self.graph_runtime_state.variable_pool)
new_instance.graph_runtime_state.total_tokens = 0
return new_instance return new_instance


def _handle_continue_on_error( def _handle_continue_on_error(

+ 0
- 1
api/core/workflow/nodes/iteration/iteration_node.py View File

with flask_app.app_context(): with flask_app.app_context():
parallel_mode_run_id = uuid.uuid4().hex parallel_mode_run_id = uuid.uuid4().hex
graph_engine_copy = graph_engine.create_copy() graph_engine_copy = graph_engine.create_copy()
graph_engine_copy.graph_runtime_state.total_tokens = 0
variable_pool_copy = graph_engine_copy.graph_runtime_state.variable_pool variable_pool_copy = graph_engine_copy.graph_runtime_state.variable_pool
variable_pool_copy.add([self.node_id, "index"], index) variable_pool_copy.add([self.node_id, "index"], index)
variable_pool_copy.add([self.node_id, "item"], item) variable_pool_copy.add([self.node_id, "item"], item)

Loading…
Cancel
Save