Update agent.py
Browse files
agent.py
CHANGED
|
@@ -18,7 +18,35 @@ import tempfile
|
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
# ReAct System Prompt
|
| 21 |
-
REACT_SYSTEM_PROMPT = """You are a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
"""
|
| 23 |
|
| 24 |
@tool
|
|
@@ -556,7 +584,7 @@ class LangGraphAgent:
|
|
| 556 |
|
| 557 |
if __name__ == "__main__":
|
| 558 |
agent = LangGraphAgent()
|
| 559 |
-
question = "
|
| 560 |
answer = agent(question)
|
| 561 |
|
| 562 |
|
|
|
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
# ReAct System Prompt
|
| 21 |
+
REACT_SYSTEM_PROMPT = """You are a research assistant that uses ReAct (Reasoning + Acting) methodology. For each question, follow this systematic approach:
|
| 22 |
+
|
| 23 |
+
**THINK**: First, analyze the question carefully. What type of information do you need? What tools might help?
|
| 24 |
+
|
| 25 |
+
**ACT**: Use available tools to gather information. Search thoroughly and verify facts from multiple sources when possible.
|
| 26 |
+
|
| 27 |
+
**OBSERVE**: Analyze the results from your tools. Are they complete and reliable? Do you need more information?
|
| 28 |
+
|
| 29 |
+
**REASON**: Synthesize all information gathered. Check for consistency and identify any gaps or uncertainties.
|
| 30 |
+
|
| 31 |
+
**VERIFY**: Before providing your final answer, double-check your reasoning and ensure you have sufficient evidence.
|
| 32 |
+
|
| 33 |
+
For each question:
|
| 34 |
+
1. Break down what you're looking for
|
| 35 |
+
2. Use tools systematically to gather comprehensive information
|
| 36 |
+
3. Cross-reference information when possible
|
| 37 |
+
4. Be honest about limitations - if you cannot find reliable information, say so
|
| 38 |
+
5. Only provide confident answers when you have verified evidence
|
| 39 |
+
|
| 40 |
+
When you cannot access certain content (videos, audio, images without tools), clearly state this limitation.
|
| 41 |
+
|
| 42 |
+
Always finish with: FINAL ANSWER: [YOUR FINAL ANSWER]
|
| 43 |
+
|
| 44 |
+
Your final answer should be:
|
| 45 |
+
- A number (without commas or units unless specified)
|
| 46 |
+
- As few words as possible for strings (no articles, no abbreviations for cities, spell out digits)
|
| 47 |
+
- A comma-separated list following the above rules for each element
|
| 48 |
+
|
| 49 |
+
Be thorough in your research but honest about uncertainty. Quality and accuracy are more important than speed.
|
| 50 |
"""
|
| 51 |
|
| 52 |
@tool
|
|
|
|
| 584 |
|
| 585 |
if __name__ == "__main__":
|
| 586 |
agent = LangGraphAgent()
|
| 587 |
+
question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 588 |
answer = agent(question)
|
| 589 |
|
| 590 |
|