beyzapehlivan commited on
Commit
0519fb9
·
verified ·
1 Parent(s): 208a35f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -14
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
- # DuckDuckGoSearchTool'u listeden çıkardık çünkü add_base_tools=True onu getiriyor.
20
- # VisitWebpageTool'u ise özel olarak eklemeye devam ediyoruz.
 
 
 
 
 
21
  self.agent = CodeAgent(
22
  tools=[VisitWebpageTool()],
23
  model=model,
24
- max_steps=6, # 12'den 6'ya düşürdük, tıkanmaları engelleyecek
25
  add_base_tools=True,
26
- planning_interval=2 # Modeli her 2 adımda bir stratejisini gözden geçirmeye zorlar
 
27
  )
28
- print("AlfredAgent başarıyla kuruldu. Hızlı mod aktif.")
29
 
30
  def __call__(self, question: str) -> str:
31
- prompt = f"""You are a world-class solver for the GAIA benchmark.
32
- Solve the task below and provide ONLY the absolute final result.
33
-
34
- RULES:
35
- - If the answer is a name, provide only the name (e.g., 'Albert Einstein').
36
- - If the answer is a number, provide only the digits (e.g., '14.5').
37
- - If the answer is a date, use YYYY-MM-DD format.
38
- - NO EXPLANATIONS. NO "The answer is...". NO punctuation at the end.
 
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}"