Update app.py
Browse files
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 |
-
#
|
187 |
-
#
|
188 |
-
#
|
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 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
"""
|