Yatsrib commited on
Commit
7600e7e
·
verified ·
1 Parent(s): 5e06015

Update Gradio_UI.py

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