Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ def tavily_search(query: str) -> str:
|
|
38 |
str: Formatted search results.
|
39 |
"""
|
40 |
try:
|
41 |
-
client = TavilyClient()
|
42 |
results = client.search(query=query, max_results=5)
|
43 |
|
44 |
formatted = []
|
@@ -185,14 +185,17 @@ When you've found the answer, stop reasoning and return ONLY the answer.
|
|
185 |
model="gpt-4o-mini"
|
186 |
)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
196 |
|
197 |
# result = Runner.run_sync(
|
198 |
# my_agent,
|
|
|
38 |
str: Formatted search results.
|
39 |
"""
|
40 |
try:
|
41 |
+
client = TavilyClient(os.getenv("TAVILY_API_KEY"))
|
42 |
results = client.search(query=query, max_results=5)
|
43 |
|
44 |
formatted = []
|
|
|
185 |
model="gpt-4o-mini"
|
186 |
)
|
187 |
|
188 |
+
for update in Runner.run_streamed(my_agent, input=question, max_turns=25):
|
189 |
+
if update.new_items:
|
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 |
+
# Final answer is in update.final_output (from the last loop iteration)
|
197 |
+
print(f"Agent gave answer (first 50 chars): {update.final_output[:50]}...")
|
198 |
+
return update.final_output
|
199 |
|
200 |
# result = Runner.run_sync(
|
201 |
# my_agent,
|