Spaces:
Sleeping
Sleeping
mriusero
commited on
Commit
·
b6f3c79
1
Parent(s):
f571b45
fix: thoughts streaming
Browse files- src/agent/stream.py +17 -12
src/agent/stream.py
CHANGED
@@ -100,15 +100,15 @@ async def respond(message, history=None, state=None):
|
|
100 |
#else:
|
101 |
# history[-1] = ChatMessage(role="assistant", content=buffer, metadata={"title": "Acting...", "status": "pending", "id": state['cycle']+1, 'parent_id': state["cycle"]})
|
102 |
|
103 |
-
elif current_phase == "observe":
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
yield history
|
112 |
|
113 |
if current_phase == "final":
|
114 |
delta_content = delta.content or ""
|
@@ -202,12 +202,17 @@ async def respond(message, history=None, state=None):
|
|
202 |
parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
203 |
if parent_message:
|
204 |
parent_message.content += "\n\n" + observe_text
|
205 |
-
parent_message.metadata["title"] = "
|
206 |
-
parent_message.metadata["status"] = "
|
207 |
else:
|
208 |
-
history[-1] = ChatMessage(role="assistant", content=observe_text, metadata={"title": "
|
209 |
|
210 |
if final_text:
|
|
|
|
|
|
|
|
|
|
|
211 |
history.append(ChatMessage(role="assistant", content=final_text))
|
212 |
|
213 |
last_message = messages[-1]
|
|
|
100 |
#else:
|
101 |
# history[-1] = ChatMessage(role="assistant", content=buffer, metadata={"title": "Acting...", "status": "pending", "id": state['cycle']+1, 'parent_id': state["cycle"]})
|
102 |
|
103 |
+
#elif current_phase == "observe":
|
104 |
+
# parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
105 |
+
# if parent_message:
|
106 |
+
# parent_message.content += "\n\n" + buffer
|
107 |
+
# parent_message.metadata["title"] = "Acting..."
|
108 |
+
# else:
|
109 |
+
# history[-1] = ChatMessage(role="assistant", content=buffer, metadata={"title": "Observing...", "status": "pending", "id": state['cycle']+2, 'parent_id': state["cycle"]})
|
110 |
+
#
|
111 |
+
#yield history
|
112 |
|
113 |
if current_phase == "final":
|
114 |
delta_content = delta.content or ""
|
|
|
202 |
parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
203 |
if parent_message:
|
204 |
parent_message.content += "\n\n" + observe_text
|
205 |
+
parent_message.metadata["title"] = "Observing..."
|
206 |
+
parent_message.metadata["status"] = "pending"
|
207 |
else:
|
208 |
+
history[-1] = ChatMessage(role="assistant", content=observe_text, metadata={"title": "Observing...", "status": "pending", "id": state['cycle']+2, 'parent_id': state["cycle"]})
|
209 |
|
210 |
if final_text:
|
211 |
+
parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
212 |
+
if parent_message:
|
213 |
+
parent_message.metadata["title"] = "Thoughts"
|
214 |
+
parent_message.metadata["status"] = "done"
|
215 |
+
|
216 |
history.append(ChatMessage(role="assistant", content=final_text))
|
217 |
|
218 |
last_message = messages[-1]
|