ahmer64 commited on
Commit
7ca8465
·
verified ·
1 Parent(s): 4e59f65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -30
app.py CHANGED
@@ -15,12 +15,11 @@ import os
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
- print("Final Working Agent initialized.")
19
 
20
- hf_token = os.getenv("Sayyid")
21
  print("TOKEN EXISTS:", hf_token is not None)
22
 
23
- # ✅ Use a model that is guaranteed to work
24
  self.model = InferenceClientModel(
25
  model_id="HuggingFaceH4/zephyr-7b-beta",
26
  provider="hf-inference",
@@ -36,43 +35,23 @@ class BasicAgent:
36
 
37
  def clean(self, ans):
38
  ans = str(ans).strip()
39
- ans = ans.replace("FINAL ANSWER:", "")
40
- ans = ans.replace("Final Answer:", "")
41
- ans = ans.replace("final answer:", "")
42
- ans = ans.strip()
43
-
44
- if "\n" in ans:
45
- ans = ans.split("\n")[0].strip()
46
-
47
- return ans
48
 
49
  def __call__(self, question: str) -> str:
50
- print("Q:", question[:100])
51
-
52
  prompt = f"""
53
- You are solving an exact-answer benchmark.
54
-
55
  Return ONLY the final answer.
56
- No explanation.
57
- No extra words.
58
- No "FINAL ANSWER".
59
 
60
  Question:
61
  {question}
62
  """
63
-
64
  try:
65
- answer = self.agent.run(prompt)
66
- final = self.clean(answer)
67
-
68
- if final == "" or final.lower() in ["none", "unknown", "error"]:
69
- return "unknown"
70
-
71
- print("FINAL:", final)
72
- return final
73
-
74
  except Exception as e:
75
- print("AGENT ERROR:", e)
76
  return "unknown"
77
 
78
  def run_and_submit_all( profile: gr.OAuthProfile | None):
 
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
+ print("Final Agent initialized.")
19
 
20
+ hf_token = os.getenv("HF_TOKEN")
21
  print("TOKEN EXISTS:", hf_token is not None)
22
 
 
23
  self.model = InferenceClientModel(
24
  model_id="HuggingFaceH4/zephyr-7b-beta",
25
  provider="hf-inference",
 
35
 
36
  def clean(self, ans):
37
  ans = str(ans).strip()
38
+ for x in ["FINAL ANSWER:", "Final Answer:", "Answer:"]:
39
+ ans = ans.replace(x, "")
40
+ return ans.split("\n")[0].strip()
 
 
 
 
 
 
41
 
42
  def __call__(self, question: str) -> str:
 
 
43
  prompt = f"""
 
 
44
  Return ONLY the final answer.
45
+ No explanation. No extra words.
 
 
46
 
47
  Question:
48
  {question}
49
  """
 
50
  try:
51
+ ans = self.agent.run(prompt)
52
+ return self.clean(ans)
 
 
 
 
 
 
 
53
  except Exception as e:
54
+ print("ERROR:", e)
55
  return "unknown"
56
 
57
  def run_and_submit_all( profile: gr.OAuthProfile | None):