Update app.py
Browse files
app.py
CHANGED
|
@@ -185,17 +185,23 @@ When you've found the answer, stop reasoning and return ONLY the answer.
|
|
| 185 |
model="gpt-4o-mini"
|
| 186 |
)
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
for step in update.new_items:
|
| 191 |
-
print("🧠 Thought:", step.thought)
|
| 192 |
-
print("⚙️ Action:", step.tool_call)
|
| 193 |
-
print("🔍 Observation:", step.observation)
|
| 194 |
-
print("-" * 50)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
# result = Runner.run_sync(
|
| 201 |
# my_agent,
|
|
|
|
| 185 |
model="gpt-4o-mini"
|
| 186 |
)
|
| 187 |
|
| 188 |
+
import nest_asyncio
|
| 189 |
+
import asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
+
nest_asyncio.apply()
|
| 192 |
+
|
| 193 |
+
async def run_agent_streamed():
|
| 194 |
+
async for update in Runner.run_streamed(my_agent, input=question, max_turns=25):
|
| 195 |
+
if update.new_items:
|
| 196 |
+
for step in update.new_items:
|
| 197 |
+
print("🧠 Thought:", step.thought)
|
| 198 |
+
print("⚙️ Action:", step.tool_call)
|
| 199 |
+
print("🔍 Observation:", step.observation)
|
| 200 |
+
print("-" * 50)
|
| 201 |
+
print(f"Agent gave answer (first 50 chars): {update.final_output[:50]}...")
|
| 202 |
+
return update.final_output
|
| 203 |
+
|
| 204 |
+
result = await run_agent_streamed() # If already inside an async context
|
| 205 |
|
| 206 |
# result = Runner.run_sync(
|
| 207 |
# my_agent,
|