rnrahate007 commited on
Commit
a32cdf1
·
verified ·
1 Parent(s): a8c3238

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -21,8 +21,8 @@ class BasicAgent:
21
  self.model = genai.GenerativeModel("gemini-2.5-flash")
22
 
23
  def __call__(self, question: str) -> str:
24
- try:
25
- base_prompt = f"""
26
  You are solving benchmark reasoning questions.
27
 
28
  RULES:
@@ -36,11 +36,11 @@ Question:
36
  """
37
 
38
  # 🔥 Step 1: First attempt
39
- response1 = self.model.generate_content(base_prompt)
40
- ans1 = response1.text.strip()
41
 
42
  # 🔥 Step 2: Self-check (THIS IS THE MAGIC)
43
- verify_prompt = f"""
44
  Question: {question}
45
 
46
  Proposed Answer: {ans1}
@@ -52,18 +52,18 @@ If correct, repeat the answer.
52
  Return ONLY answer.
53
  """
54
 
55
- response2 = self.model.generate_content(verify_prompt)
56
- final = response2.text.strip()
57
 
58
  # 🔥 Clean output (VERY IMPORTANT for exact match)
59
- final = final.replace("Final Answer:", "").strip()
60
- final = final.split("\n")[0].strip()
61
- final = final.split(".")[0].strip()
62
 
63
- return final[:100]
64
 
65
- except Exception as e:
66
- return "N/A"
67
 
68
 
69
 
 
21
  self.model = genai.GenerativeModel("gemini-2.5-flash")
22
 
23
  def __call__(self, question: str) -> str:
24
+ try:
25
+ base_prompt = f"""
26
  You are solving benchmark reasoning questions.
27
 
28
  RULES:
 
36
  """
37
 
38
  # 🔥 Step 1: First attempt
39
+ response1 = self.model.generate_content(base_prompt)
40
+ ans1 = response1.text.strip()
41
 
42
  # 🔥 Step 2: Self-check (THIS IS THE MAGIC)
43
+ verify_prompt = f"""
44
  Question: {question}
45
 
46
  Proposed Answer: {ans1}
 
52
  Return ONLY answer.
53
  """
54
 
55
+ response2 = self.model.generate_content(verify_prompt)
56
+ final = response2.text.strip()
57
 
58
  # 🔥 Clean output (VERY IMPORTANT for exact match)
59
+ final = final.replace("Final Answer:", "").strip()
60
+ final = final.split("\n")[0].strip()
61
+ final = final.split(".")[0].strip()
62
 
63
+ return final[:100]
64
 
65
+ except Exception as e:
66
+ return "N/A"
67
 
68
 
69