Spaces:
Running
Running
Ben Beinke
commited on
Commit
·
be38a54
1
Parent(s):
40eee5b
Ui is killer now
Browse files
app.py
CHANGED
@@ -187,13 +187,6 @@ class GradioUI:
|
|
187 |
import gradio as gr
|
188 |
|
189 |
self.parent_id = int(time.time() * 1000)
|
190 |
-
messages.append(
|
191 |
-
gr.ChatMessage(
|
192 |
-
role="assistant",
|
193 |
-
content="",
|
194 |
-
metadata={"id": self.parent_id, "title": "...", "status": "pending"},
|
195 |
-
)
|
196 |
-
)
|
197 |
# Get the agent type from the template agent
|
198 |
if "agent" not in session_state:
|
199 |
session_state["agent"] = self.agent
|
@@ -202,6 +195,18 @@ class GradioUI:
|
|
202 |
messages.append(
|
203 |
gr.ChatMessage(role="user", content=prompt, metadata={"status": "done"})
|
204 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
yield messages
|
206 |
|
207 |
for msg in stream_to_gradio(
|
@@ -223,6 +228,9 @@ class GradioUI:
|
|
223 |
and message.metadata.get("id") == self.parent_id
|
224 |
):
|
225 |
message.metadata["status"] = "done"
|
|
|
|
|
|
|
226 |
break
|
227 |
elif isinstance(msg, str): # Then it's only a completion delta
|
228 |
msg = msg.replace("<", r"\<").replace(
|
|
|
187 |
import gradio as gr
|
188 |
|
189 |
self.parent_id = int(time.time() * 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
# Get the agent type from the template agent
|
191 |
if "agent" not in session_state:
|
192 |
session_state["agent"] = self.agent
|
|
|
195 |
messages.append(
|
196 |
gr.ChatMessage(role="user", content=prompt, metadata={"status": "done"})
|
197 |
)
|
198 |
+
messages.append(
|
199 |
+
gr.ChatMessage(
|
200 |
+
role="assistant",
|
201 |
+
content="",
|
202 |
+
metadata={
|
203 |
+
"id": self.parent_id,
|
204 |
+
"title": "🧠 Thinking...",
|
205 |
+
"status": "pending",
|
206 |
+
},
|
207 |
+
)
|
208 |
+
)
|
209 |
+
start_time = time.time()
|
210 |
yield messages
|
211 |
|
212 |
for msg in stream_to_gradio(
|
|
|
228 |
and message.metadata.get("id") == self.parent_id
|
229 |
):
|
230 |
message.metadata["status"] = "done"
|
231 |
+
message.metadata["title"] = (
|
232 |
+
f"🧠 Thought for {time.time() - start_time:.0f} sec."
|
233 |
+
)
|
234 |
break
|
235 |
elif isinstance(msg, str): # Then it's only a completion delta
|
236 |
msg = msg.replace("<", r"\<").replace(
|