GiovannaMariotto commited on
Commit
53682bd
·
verified ·
1 Parent(s): c90f7ba

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +16 -5
Gradio_UI.py CHANGED
@@ -109,12 +109,23 @@ def pull_messages_from_step(
109
  yield gr.ChatMessage(role="assistant", content=str(step_log.error), metadata={"title": "💥 Error"})
110
 
111
  # Calculate duration and token information
 
 
 
 
 
 
 
112
  step_footnote = f"{step_number}"
113
- if hasattr(step_log, "input_token_count") and hasattr(step_log, "output_token_count"):
114
- token_str = (
115
- f" | Input-tokens:{step_log.input_token_count:,} | Output-tokens:{step_log.output_token_count:,}"
116
- )
117
- step_footnote += token_str
 
 
 
 
118
  if hasattr(step_log, "duration"):
119
  step_duration = f" | Duration: {round(float(step_log.duration), 2)}" if step_log.duration else None
120
  step_footnote += step_duration
 
109
  yield gr.ChatMessage(role="assistant", content=str(step_log.error), metadata={"title": "💥 Error"})
110
 
111
  # Calculate duration and token information
112
+ #step_footnote = f"{step_number}"
113
+ #if hasattr(step_log, "input_token_count") and hasattr(step_log, "output_token_count"):
114
+ # token_str = (
115
+ # f" | Input-tokens:{step_log.input_token_count:,} | Output-tokens:{step_log.output_token_count:,}"
116
+ # )
117
+ # step_footnote += token_str
118
+
119
  step_footnote = f"{step_number}"
120
+ input_tokens = getattr(step_log, "input_token_count", None)
121
+ output_tokens = getattr(step_log, "output_token_count", None)
122
+
123
+ if input_tokens is not None:
124
+ step_footnote += f" | Input-tokens:{input_tokens:,}"
125
+ if output_tokens is not None:
126
+ step_footnote += f" | Output-tokens:{output_tokens:,}"
127
+
128
+
129
  if hasattr(step_log, "duration"):
130
  step_duration = f" | Duration: {round(float(step_log.duration), 2)}" if step_log.duration else None
131
  step_footnote += step_duration