Update app.py
Browse files
app.py
CHANGED
|
@@ -16,30 +16,37 @@ model = HfApiModel(model_id="Qwen/Qwen2.5-72B-Instruct", token=token)
|
|
| 16 |
|
| 17 |
class AlfredAgent:
|
| 18 |
def __init__(self):
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
self.agent = CodeAgent(
|
| 22 |
tools=[VisitWebpageTool()],
|
| 23 |
model=model,
|
| 24 |
-
max_steps=
|
| 25 |
add_base_tools=True,
|
| 26 |
-
planning_interval=2
|
|
|
|
| 27 |
)
|
| 28 |
-
print("AlfredAgent başarıyla kuruldu.
|
| 29 |
|
| 30 |
def __call__(self, question: str) -> str:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
Task: {question}"""
|
| 41 |
try:
|
| 42 |
result = self.agent.run(prompt)
|
|
|
|
| 43 |
return str(result).strip()
|
| 44 |
except Exception as e:
|
| 45 |
return f"Error: {e}"
|
|
|
|
| 16 |
|
| 17 |
class AlfredAgent:
|
| 18 |
def __init__(self):
|
| 19 |
+
# Alfred'e görev bilinci aşılayan özel talimatlar
|
| 20 |
+
CUSTOM_SYSTEM_PROMPT = """You are a highly efficient GAIA solver.
|
| 21 |
+
1. When you visit a page, look specifically for tables or lists related to the question.
|
| 22 |
+
2. If a page is too long or messy, use search to find a better source (like Wikipedia).
|
| 23 |
+
3. Always provide the answer in the requested format (Year, Name, or Number).
|
| 24 |
+
4. If you are stuck in a loop, try a different search query or move to a different website."""
|
| 25 |
+
|
| 26 |
self.agent = CodeAgent(
|
| 27 |
tools=[VisitWebpageTool()],
|
| 28 |
model=model,
|
| 29 |
+
max_steps=9, # 6 çok az, 12 çok fazlaydı. 9 ideal bir denge.
|
| 30 |
add_base_tools=True,
|
| 31 |
+
planning_interval=2,
|
| 32 |
+
system_prompt=CUSTOM_SYSTEM_PROMPT # Alfred artık ne yapacağını biliyor
|
| 33 |
)
|
| 34 |
+
print("AlfredAgent başarıyla kuruldu. Akıllı mod aktif.")
|
| 35 |
|
| 36 |
def __call__(self, question: str) -> str:
|
| 37 |
+
# Kuralları burada da pekiştiriyoruz
|
| 38 |
+
prompt = f"""Task: {question}
|
| 39 |
+
|
| 40 |
+
RULES:
|
| 41 |
+
- Provide ONLY the final answer.
|
| 42 |
+
- If it's a number: only digits (e.g. 42).
|
| 43 |
+
- If it's a name: only the name.
|
| 44 |
+
- If it's a date: YYYY-MM-DD.
|
| 45 |
+
- No conversational filler (no "The answer is")."""
|
| 46 |
|
|
|
|
| 47 |
try:
|
| 48 |
result = self.agent.run(prompt)
|
| 49 |
+
# Alfred bazen çok uzun cevap verebilir, sadece son satırı almayı deneyelim
|
| 50 |
return str(result).strip()
|
| 51 |
except Exception as e:
|
| 52 |
return f"Error: {e}"
|