patricksamuel commited on
Commit
5ea72fa
Β·
verified Β·
1 Parent(s): 8f04303

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -20
app.py CHANGED
@@ -178,32 +178,49 @@ When you've found the answer, stop reasoning and return ONLY the answer.
178
  my_agent = Agent(
179
  name="Expert Question Answering Agent",
180
  instructions=instructions,
181
- tools = [
182
  tavily_search,
183
  visit_website
184
  ],
185
  model="gpt-4o-mini"
186
- # model=LitellmModel(
187
- # model="gemini/gemini-2.5-flash",
188
- # api_key=os.getenv("GEMINI_API_KEY")
189
- # )
190
-
191
  )
192
-
193
- result = Runner.run_sync(
194
- my_agent,
195
- input=question,
196
- max_turns=25
197
- )
198
  print("\n--- Intermediate Reasoning ---")
199
- for step in result.steps:
200
- print("🧠 Thought:", step.thought)
201
- print("βš™οΈ Action:", step.tool_call)
202
- print("πŸ” Observation:", step.observation)
203
- print("-" * 50)
204
-
205
- print(f"Agent returning fixed answer(first 50 chars): {result.final_output[:50]}...")
206
- return result.final_output
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
  def run_and_submit_all( profile: gr.OAuthProfile | None):
209
  """
 
178
  my_agent = Agent(
179
  name="Expert Question Answering Agent",
180
  instructions=instructions,
181
+ tools=[
182
  tavily_search,
183
  visit_website
184
  ],
185
  model="gpt-4o-mini"
186
+ # OR for Gemini:
187
+ # model=LitellmModel(
188
+ # model="gemini/gemini-2.5-flash",
189
+ # api_key=os.getenv("GEMINI_API_KEY")
190
+ # )
191
  )
192
+
 
 
 
 
 
193
  print("\n--- Intermediate Reasoning ---")
194
+ final_answer = None
195
+ stream = Runner.run_streamed(my_agent, input=question, max_turns=25)
196
+
197
+ for event in stream:
198
+ if event.thought:
199
+ print("🧠 Thought:", event.thought)
200
+ if event.tool_call:
201
+ print("βš™οΈ Action:", event.tool_call)
202
+ if event.observation:
203
+ print("πŸ” Observation:", event.observation)
204
+ if event.final_output:
205
+ print(f"βœ… Final Answer: {event.final_output}")
206
+ final_answer = event.final_output
207
+
208
+ return final_answer
209
+
210
+ # result = Runner.run_sync(
211
+ # my_agent,
212
+ # input=question,
213
+ # max_turns=25
214
+ # )
215
+ # print("\n--- Intermediate Reasoning ---")
216
+ # for step in result.steps:
217
+ # print("🧠 Thought:", step.thought)
218
+ # print("βš™οΈ Action:", step.tool_call)
219
+ # print("πŸ” Observation:", step.observation)
220
+ # print("-" * 50)
221
+
222
+ # print(f"Agent returning fixed answer(first 50 chars): {result.final_output[:50]}...")
223
+ # return result.final_output
224
 
225
  def run_and_submit_all( profile: gr.OAuthProfile | None):
226
  """