RozzaCreat commited on
Commit
beebc14
·
verified ·
1 Parent(s): 9fa0d97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -36,14 +36,27 @@ class BasicAgent:
36
  max_steps=12,
37
  additional_authorized_imports=["pandas", "numpy"],
38
  )
 
 
 
 
 
 
39
 
40
- def __call__(self, question: str) -> str:
41
- try:
42
- return str(self.agent.run(f"{SYSTEM_HINT}\n\nQuestion: {question}"))
43
- except Exception as e:
44
- print(f"Agent failed on question: {e}")
45
- return "unable to answer"
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
 
49
 
 
36
  max_steps=12,
37
  additional_authorized_imports=["pandas", "numpy"],
38
  )
39
+ GAIA_SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template:
40
+ FINAL ANSWER: [YOUR FINAL ANSWER].
41
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
42
+ If you are asked for a number, don't use commas to write your number, and don't use units such as $ or percent sign unless specified otherwise.
43
+ If you are asked for a string, don't use articles, don't use abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
44
+ If you are asked for a comma separated list, apply the above rules depending on whether the element to be put in the list is a number or a string."""
45
 
 
 
 
 
 
 
46
 
47
+ def __call__(self, question: str) -> str:
48
+ try:
49
+ raw = str(self.agent.run(f"{GAIA_SYSTEM_PROMPT}\n\nQuestion: {question}"))
50
+ # Извлекаем только то, что после "FINAL ANSWER:"
51
+ if "FINAL ANSWER:" in raw:
52
+ answer = raw.split("FINAL ANSWER:")[-1].strip()
53
+ # Убираем точку в конце, если есть
54
+ answer = answer.rstrip(".").strip()
55
+ return answer
56
+ return raw.strip()
57
+ except Exception as e:
58
+ print(f"Agent failed: {e}")
59
+ return "unable to answer"
60
 
61
 
62