mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 12:56:01 +08:00
Revert "fix: total tokens is wrong which is zero in inter way, close … (#11536)
This commit is contained in:
parent
afffd345bc
commit
225fcd5e41
@ -127,7 +127,6 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCyc
|
|||||||
|
|
||||||
self._conversation_name_generate_thread = None
|
self._conversation_name_generate_thread = None
|
||||||
self._recorded_files: list[Mapping[str, Any]] = []
|
self._recorded_files: list[Mapping[str, Any]] = []
|
||||||
self.total_tokens: int = 0
|
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
"""
|
"""
|
||||||
@ -361,8 +360,6 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCyc
|
|||||||
if not workflow_run:
|
if not workflow_run:
|
||||||
raise Exception("Workflow run not initialized.")
|
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 0
|
|
||||||
yield self._workflow_iteration_completed_to_stream_response(
|
yield self._workflow_iteration_completed_to_stream_response(
|
||||||
task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event
|
task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event
|
||||||
)
|
)
|
||||||
@ -376,7 +373,7 @@ class AdvancedChatAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCyc
|
|||||||
workflow_run = self._handle_workflow_run_success(
|
workflow_run = self._handle_workflow_run_success(
|
||||||
workflow_run=workflow_run,
|
workflow_run=workflow_run,
|
||||||
start_at=graph_runtime_state.start_at,
|
start_at=graph_runtime_state.start_at,
|
||||||
total_tokens=graph_runtime_state.total_tokens or self.total_tokens,
|
total_tokens=graph_runtime_state.total_tokens,
|
||||||
total_steps=graph_runtime_state.node_run_steps,
|
total_steps=graph_runtime_state.node_run_steps,
|
||||||
outputs=event.outputs,
|
outputs=event.outputs,
|
||||||
conversation_id=self._conversation.id,
|
conversation_id=self._conversation.id,
|
||||||
|
@ -106,7 +106,6 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMa
|
|||||||
|
|
||||||
self._task_state = WorkflowTaskState()
|
self._task_state = WorkflowTaskState()
|
||||||
self._wip_workflow_node_executions = {}
|
self._wip_workflow_node_executions = {}
|
||||||
self.total_tokens: int = 0
|
|
||||||
|
|
||||||
def process(self) -> Union[WorkflowAppBlockingResponse, Generator[WorkflowAppStreamResponse, None, None]]:
|
def process(self) -> Union[WorkflowAppBlockingResponse, Generator[WorkflowAppStreamResponse, None, None]]:
|
||||||
"""
|
"""
|
||||||
@ -320,8 +319,6 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMa
|
|||||||
if not workflow_run:
|
if not workflow_run:
|
||||||
raise Exception("Workflow run not initialized.")
|
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 0
|
|
||||||
yield self._workflow_iteration_completed_to_stream_response(
|
yield self._workflow_iteration_completed_to_stream_response(
|
||||||
task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event
|
task_id=self._application_generate_entity.task_id, workflow_run=workflow_run, event=event
|
||||||
)
|
)
|
||||||
@ -335,7 +332,7 @@ class WorkflowAppGenerateTaskPipeline(BasedGenerateTaskPipeline, WorkflowCycleMa
|
|||||||
workflow_run = self._handle_workflow_run_success(
|
workflow_run = self._handle_workflow_run_success(
|
||||||
workflow_run=workflow_run,
|
workflow_run=workflow_run,
|
||||||
start_at=graph_runtime_state.start_at,
|
start_at=graph_runtime_state.start_at,
|
||||||
total_tokens=graph_runtime_state.total_tokens or self.total_tokens,
|
total_tokens=graph_runtime_state.total_tokens,
|
||||||
total_steps=graph_runtime_state.node_run_steps,
|
total_steps=graph_runtime_state.node_run_steps,
|
||||||
outputs=event.outputs,
|
outputs=event.outputs,
|
||||||
conversation_id=None,
|
conversation_id=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user