Spaces:
Sleeping
Sleeping
Shourya Angrish commited on
Commit ·
c0c82d2
1
Parent(s): b86ce16
adding dependencies
Browse files- Gradio_UI.py +8 -8
Gradio_UI.py
CHANGED
|
@@ -142,15 +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 |
-
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
if isinstance(step_log, ActionStep):
|
| 148 |
-
step_log.input_token_count =
|
| 149 |
-
step_log.output_token_count =
|
| 150 |
-
|
| 151 |
-
for message in pull_messages_from_step(
|
| 152 |
-
step_log,
|
| 153 |
-
):
|
| 154 |
yield message
|
| 155 |
|
| 156 |
final_answer = step_log # Last log is the run's final_answer
|
|
|
|
| 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 |
+
last_input_token_count = agent.model.last_input_token_count or 0
|
| 146 |
+
last_output_token_count = agent.model.last_output_token_count or 0
|
| 147 |
+
total_input_tokens += last_input_token_count
|
| 148 |
+
total_output_tokens += last_output_token_count
|
| 149 |
if isinstance(step_log, ActionStep):
|
| 150 |
+
step_log.input_token_count = last_input_token_count
|
| 151 |
+
step_log.output_token_count = last_output_token_count
|
| 152 |
+
|
| 153 |
+
for message in pull_messages_from_step(step_log):
|
|
|
|
|
|
|
| 154 |
yield message
|
| 155 |
|
| 156 |
final_answer = step_log # Last log is the run's final_answer
|