Update app.py
Browse files
app.py
CHANGED
@@ -179,44 +179,18 @@ When you've found the answer, stop reasoning and return ONLY the answer.
|
|
179 |
my_agent = Agent(
|
180 |
name="Expert Question Answering Agent",
|
181 |
instructions=instructions,
|
182 |
-
tools=[
|
183 |
-
|
184 |
visit_website
|
185 |
],
|
186 |
model="gpt-4o-mini"
|
187 |
-
# OR for Gemini:
|
188 |
-
# model=LitellmModel(
|
189 |
-
# model="gemini/gemini-2.5-flash",
|
190 |
-
# api_key=os.getenv("GEMINI_API_KEY")
|
191 |
-
# )
|
192 |
)
|
193 |
-
|
194 |
-
print("\n--- Intermediate Reasoning ---")
|
195 |
-
|
196 |
-
result = Runner.run_streamed(my_agent, input=question, max_turns=25)
|
197 |
-
|
198 |
-
print("=== Run starting ===")
|
199 |
-
|
200 |
-
async for event in result.stream_events():
|
201 |
-
# We'll ignore the raw responses event deltas
|
202 |
-
if event.type == "raw_response_event":
|
203 |
-
continue
|
204 |
-
# When the agent updates, print that
|
205 |
-
elif event.type == "agent_updated_stream_event":
|
206 |
-
print(f"Agent updated: {event.new_agent.name}")
|
207 |
-
continue
|
208 |
-
# When items are generated, print them
|
209 |
-
elif event.type == "run_item_stream_event":
|
210 |
-
if event.item.type == "tool_call_item":
|
211 |
-
print("-- Tool was called")
|
212 |
-
elif event.item.type == "tool_call_output_item":
|
213 |
-
print(f"-- Tool output: {event.item.output}")
|
214 |
-
elif event.item.type == "message_output_item":
|
215 |
-
print(f"-- Message output:\n {ItemHelpers.text_message_output(event.item)}")
|
216 |
-
else:
|
217 |
-
pass # Ignore other event types
|
218 |
-
|
219 |
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
print(f"Agent gave answer (first 50 chars): {result.final_output[:50]}...")
|
222 |
return result.final_output
|
|
|
179 |
my_agent = Agent(
|
180 |
name="Expert Question Answering Agent",
|
181 |
instructions=instructions,
|
182 |
+
tools = [
|
183 |
+
web_search,
|
184 |
visit_website
|
185 |
],
|
186 |
model="gpt-4o-mini"
|
|
|
|
|
|
|
|
|
|
|
187 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
+
result = Runner.run_sync(
|
190 |
+
my_agent,
|
191 |
+
input=question,
|
192 |
+
max_turns=25
|
193 |
+
)
|
194 |
|
195 |
print(f"Agent gave answer (first 50 chars): {result.final_output[:50]}...")
|
196 |
return result.final_output
|