Spaces:
Sleeping
Sleeping
version complète v09
Browse files- agent.py +3 -17
- prompt.txt +27 -0
- test.py +1 -1
agent.py
CHANGED
|
@@ -11,27 +11,13 @@ load_dotenv()
|
|
| 11 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 12 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 13 |
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
# 🧠 Création de l'agent
|
| 17 |
llm = OpenAI(
|
| 18 |
model="gpt-3.5-turbo",
|
| 19 |
-
system_prompt=(
|
| 20 |
-
You are a GAIA benchmark agent.
|
| 21 |
-
|
| 22 |
-
RULES:
|
| 23 |
-
- Respond ONLY with the final answer.
|
| 24 |
-
- Do NOT include explanations, reasoning, full sentences, or labels like "Answer:".
|
| 25 |
-
- If the answer is a number, respond with the number alone.
|
| 26 |
-
- If the answer is a word or phrase, write it exactly.
|
| 27 |
-
- Never repeat the question.
|
| 28 |
-
|
| 29 |
-
Examples:
|
| 30 |
-
"How many albums?" → 4
|
| 31 |
-
"What surname?" → Smith
|
| 32 |
-
"Which country?" → France
|
| 33 |
-
"""
|
| 34 |
-
),
|
| 35 |
max_tokens=1500,
|
| 36 |
temperature=0.1
|
| 37 |
)
|
|
|
|
| 11 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 12 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 13 |
|
| 14 |
+
with open("prompt.txt", "r", encoding="utf-8") as f:
|
| 15 |
+
my_prompt = f.read()
|
| 16 |
|
| 17 |
# 🧠 Création de l'agent
|
| 18 |
llm = OpenAI(
|
| 19 |
model="gpt-3.5-turbo",
|
| 20 |
+
system_prompt=(my_prompt),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
max_tokens=1500,
|
| 22 |
temperature=0.1
|
| 23 |
)
|
prompt.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
system_prompt = """
|
| 2 |
+
# GAIA Benchmark Agent
|
| 3 |
+
|
| 4 |
+
You are an expert research agent for GAIA benchmark questions.
|
| 5 |
+
|
| 6 |
+
## MANDATORY WORKFLOW
|
| 7 |
+
1. **ALWAYS use available tools** to research and find information
|
| 8 |
+
2. **NEVER say "I cannot answer"** - always attempt to use tools first
|
| 9 |
+
3. **Use web_search for ALL factual questions** that require current information
|
| 10 |
+
4. **Try multiple search approaches** if the first search doesn't give good results
|
| 11 |
+
|
| 12 |
+
## OUTPUT FORMAT RULES
|
| 13 |
+
- Respond with ONLY the final answer
|
| 14 |
+
- No explanations, no reasoning, no "Answer:" labels
|
| 15 |
+
- If number → just the number: `4`
|
| 16 |
+
- If word/name → just the word: `Smith`
|
| 17 |
+
- If list → comma-separated: `a,b,c` (no spaces after commas)
|
| 18 |
+
- If country code → just the code: `USA`
|
| 19 |
+
|
| 20 |
+
## Examples
|
| 21 |
+
- Question: "How many albums did X release?" → `4`
|
| 22 |
+
- Question: "What is the surname of Y?" → `Johnson`
|
| 23 |
+
- Question: "List the vegetables:" → `broccoli,celery,lettuce`
|
| 24 |
+
|
| 25 |
+
## CRITICAL RULE
|
| 26 |
+
**ALWAYS use tools before responding. NEVER give up without trying.**
|
| 27 |
+
"""
|
test.py
CHANGED
|
@@ -16,7 +16,7 @@ except Exception as e:
|
|
| 16 |
print(f"❌ Erreur DuckDuckGo: {e}")
|
| 17 |
|
| 18 |
# Testez avec une question simple
|
| 19 |
-
question_test = "How many studio albums were published by Mercedes Sosa between 2000 and 2009
|
| 20 |
|
| 21 |
expected_type = detect_answer_type(question_test)
|
| 22 |
print(expected_type)
|
|
|
|
| 16 |
print(f"❌ Erreur DuckDuckGo: {e}")
|
| 17 |
|
| 18 |
# Testez avec une question simple
|
| 19 |
+
question_test = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 20 |
|
| 21 |
expected_type = detect_answer_type(question_test)
|
| 22 |
print(expected_type)
|