mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 05:55:52 +08:00
fix: wrong token usage in iteration node for streaming result (#5336)
This commit is contained in:
parent
132f5fb3de
commit
9b7fdadce4
@ -367,7 +367,7 @@ class IterationNodeNextStreamResponse(StreamResponse):
|
|||||||
|
|
||||||
class IterationNodeCompletedStreamResponse(StreamResponse):
|
class IterationNodeCompletedStreamResponse(StreamResponse):
|
||||||
"""
|
"""
|
||||||
NodeStartStreamResponse entity
|
NodeCompletedStreamResponse entity
|
||||||
"""
|
"""
|
||||||
class Data(BaseModel):
|
class Data(BaseModel):
|
||||||
"""
|
"""
|
||||||
@ -385,6 +385,7 @@ class IterationNodeCompletedStreamResponse(StreamResponse):
|
|||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
elapsed_time: float
|
elapsed_time: float
|
||||||
total_tokens: int
|
total_tokens: int
|
||||||
|
execution_metadata: Optional[dict] = None
|
||||||
finished_at: int
|
finished_at: int
|
||||||
steps: int
|
steps: int
|
||||||
|
|
||||||
|
@ -95,6 +95,9 @@ class WorkflowIterationCycleManage(WorkflowCycleStateManager):
|
|||||||
error=None,
|
error=None,
|
||||||
elapsed_time=time.perf_counter() - current_iteration.started_at,
|
elapsed_time=time.perf_counter() - current_iteration.started_at,
|
||||||
total_tokens=current_iteration.total_tokens,
|
total_tokens=current_iteration.total_tokens,
|
||||||
|
execution_metadata={
|
||||||
|
'total_tokens': current_iteration.total_tokens,
|
||||||
|
},
|
||||||
finished_at=int(time.time()),
|
finished_at=int(time.time()),
|
||||||
steps=current_iteration.current_index
|
steps=current_iteration.current_index
|
||||||
)
|
)
|
||||||
@ -276,6 +279,9 @@ class WorkflowIterationCycleManage(WorkflowCycleStateManager):
|
|||||||
error=error,
|
error=error,
|
||||||
elapsed_time=time.perf_counter() - current_iteration.started_at,
|
elapsed_time=time.perf_counter() - current_iteration.started_at,
|
||||||
total_tokens=current_iteration.total_tokens,
|
total_tokens=current_iteration.total_tokens,
|
||||||
|
execution_metadata={
|
||||||
|
'total_tokens': current_iteration.total_tokens,
|
||||||
|
},
|
||||||
finished_at=int(time.time()),
|
finished_at=int(time.time()),
|
||||||
steps=current_iteration.current_index
|
steps=current_iteration.current_index
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user