Kackle commited on
Commit
b6c48b3
·
verified ·
1 Parent(s): 83644cb

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +7 -8
Gradio_UI.py CHANGED
@@ -143,14 +143,13 @@ def stream_to_gradio(
143
 
144
  for step_log in agent.run(task, stream=True, reset=reset_agent_memory, additional_args=additional_args):
145
  # Track tokens if model provides them
146
- if hasattr(agent.model, "last_input_token_count"):
147
- if hasattr(agent.model, "last_input_token_count") and agent.model.last_input_token_count is not None:
148
- total_input_tokens += agent.model.last_input_token_count
149
- if hasattr(agent.model, "last_output_token_count") and agent.model.last_output_token_count is not None:
150
- total_output_tokens += agent.model.last_output_token_count
151
- if isinstance(step_log, ActionStep):
152
- step_log.input_token_count = agent.model.last_input_token_count
153
- step_log.output_token_count = agent.model.last_output_token_count
154
 
155
  for message in pull_messages_from_step(
156
  step_log,
 
143
 
144
  for step_log in agent.run(task, stream=True, reset=reset_agent_memory, additional_args=additional_args):
145
  # Track tokens if model provides them
146
+ if hasattr(agent.model, "last_input_token_count") and agent.model.last_input_token_count is not None:
147
+ total_input_tokens += agent.model.last_input_token_count
148
+ if hasattr(agent.model, "last_output_token_count") and agent.model.last_output_token_count is not None:
149
+ total_output_tokens += agent.model.last_output_token_count
150
+ if isinstance(step_log, ActionStep):
151
+ step_log.input_token_count = agent.model.last_input_token_count
152
+ step_log.output_token_count = agent.model.last_output_token_count
 
153
 
154
  for message in pull_messages_from_step(
155
  step_log,