Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: total tokens is wrong which is zero in inter way, close #11221 (#11224)
yihongfd4be36991c2
diff --git a/api/core/app/apps/advanced_chat/generate_task_pipeline.py b/api/core/app/apps/advanced_chat/generate_task_pipeline.pyindex e1798957b92..0dd58133918 100644--- a/api/core/app/apps/advanced_chat/generate_task_pipeline.py+++ b/api/core/app/apps/advanced_chat/generate_task_pipeline.py@@ -125,6 +125,7 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycself._conversation_name_generate_thread = Noneself._recorded_files: list[Mapping[str, Any]] = []+ self.total_tokens: int = 0def process(self):"""@@ -358,6 +359,8 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycif not workflow_run:raise Exception("Workflow run not initialized.")+ # FIXME for issue #11221 quick fix maybe have a better solution+ self.total_tokens += event.metadata.get("total_tokens", 0) if event.metadata else 0yield self._workflow_iteration_completed_to_stream_response(task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event)@@ -371,7 +374,7 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycworkflow_run = self._handle_workflow_run_success(workflow_run=workflow_run,start_at=graph_runtime_state.start_at,- total_tokens=graph_runtime_state.total_tokens,+ total_tokens=graph_runtime_state.total_tokens or self.total_tokens,total_steps=graph_runtime_state.node_run_steps,outputs=event.outputs,conversation_id=self._conversation.id,diff --git a/api/core/app/apps/workflow/generate_task_pipeline.py b/api/core/app/apps/workflow/generate_task_pipeline.pyindex 9e4921d6a22..9966a1a9d13 100644--- a/api/core/app/apps/workflow/generate_task_pipeline.py+++ b/api/core/app/apps/workflow/generate_task_pipeline.py@@ -106,6 +106,7 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMaself._task_state = WorkflowTaskState()self._wip_workflow_node_executions = {}+ self.total_tokens: int = 0def process(self) -> Union[WorkflowAppBlockingResponse, Generator[WorkflowAppStreamResponse, None, None]]:"""@@ -319,6 +320,8 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMaif not workflow_run:raise Exception("Workflow run not initialized.")+ # FIXME for issue #11221 quick fix maybe have a better solution+ self.total_tokens += event.metadata.get("total_tokens", 0) if event.metadata else 0yield self._workflow_iteration_completed_to_stream_response(task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event)@@ -332,7 +335,7 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMaworkflow_run = self._handle_workflow_run_success(workflow_run=workflow_run,start_at=graph_runtime_state.start_at,- total_tokens=graph_runtime_state.total_tokens,+ total_tokens=graph_runtime_state.total_tokens or self.total_tokens,total_steps=graph_runtime_state.node_run_steps,outputs=event.outputs,conversation_id=None,