Update app.py
Browse files
app.py
CHANGED
@@ -139,7 +139,7 @@ class BasicAgent:
|
|
139 |
instructions = """
|
140 |
You are a ReAct (Reason-Act-Observe) agent that searches the internet to find accurate answers to questions.
|
141 |
## Available Tools
|
142 |
-
- **
|
143 |
- **visit_website**: Visit specific webpages for detailed content
|
144 |
## Output Format Rules
|
145 |
Your final answer must be **exactly one** of these formats:
|
@@ -164,45 +164,26 @@ Follow this cycle until you find the answer:
|
|
164 |
- Q: What is 15 + 27? β 42
|
165 |
- Q: What is the capital of France? β Paris
|
166 |
- Q: What are the top 3 most populous US states? β California, Texas, Florida
|
167 |
-
|
168 |
-
## Final Output Requirement
|
169 |
-
When you've found the correct answer, respond with:
|
170 |
-
|
171 |
-
## Final Output Rule
|
172 |
-
When you've found the answer, stop reasoning and return ONLY the answer.
|
173 |
-
- No "Thought", "Action", "Observation", or explanation.
|
174 |
-
- Just the answer text β for example: `California`
|
175 |
-
|
176 |
"""
|
177 |
|
178 |
my_agent = Agent(
|
179 |
name="Expert Question Answering Agent",
|
180 |
instructions=instructions,
|
181 |
tools = [
|
182 |
-
|
183 |
visit_website
|
184 |
],
|
185 |
model="gpt-4o-mini"
|
186 |
)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
if hasattr(update, "new_items") and update.new_items:
|
197 |
-
for step in update.new_items:
|
198 |
-
print("π§ Thought:", step.thought)
|
199 |
-
print("βοΈ Action:", step.tool_call)
|
200 |
-
print("π Observation:", step.observation)
|
201 |
-
print("-" * 50)
|
202 |
-
print(f"Agent gave answer (first 50 chars): {update.final_output[:50]}...")
|
203 |
-
return update.final_output
|
204 |
-
|
205 |
-
|
206 |
|
207 |
# result = Runner.run_sync(
|
208 |
# my_agent,
|
|
|
139 |
instructions = """
|
140 |
You are a ReAct (Reason-Act-Observe) agent that searches the internet to find accurate answers to questions.
|
141 |
## Available Tools
|
142 |
+
- **web_search**: Search the web for information
|
143 |
- **visit_website**: Visit specific webpages for detailed content
|
144 |
## Output Format Rules
|
145 |
Your final answer must be **exactly one** of these formats:
|
|
|
164 |
- Q: What is 15 + 27? β 42
|
165 |
- Q: What is the capital of France? β Paris
|
166 |
- Q: What are the top 3 most populous US states? β California, Texas, Florida
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
"""
|
168 |
|
169 |
my_agent = Agent(
|
170 |
name="Expert Question Answering Agent",
|
171 |
instructions=instructions,
|
172 |
tools = [
|
173 |
+
tavily_search,
|
174 |
visit_website
|
175 |
],
|
176 |
model="gpt-4o-mini"
|
177 |
)
|
178 |
|
179 |
+
result = Runner.run_sync(
|
180 |
+
my_agent,
|
181 |
+
input=question,
|
182 |
+
max_turns=25
|
183 |
+
)
|
184 |
+
print(f"Agent gave reasons {result}")
|
185 |
+
print(f"Agent gave answer (first 50 chars): {result.final_output[:50]}...")
|
186 |
+
return result.final_output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
# result = Runner.run_sync(
|
189 |
# my_agent,
|