manasagangotri commited on
Commit
9bb87f2
·
verified ·
1 Parent(s): 2d69c3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -81,28 +81,27 @@ class MathRetrievalQA(dspy.Program):
81
  return {"answer": "", "retrieved_context": ""}
82
 
83
  prompt = f"""
84
- You are a math expert writing solutions in a textbook. Provide a detailed, step-by-step solution for the following math problem.
85
 
86
- Follow these guidelines:
87
- - Use clear headings like Step wise.
88
- - Use proper mathematical notation with LaTeX.
89
- - Make the explanation educational and logically structured.
90
- - Format the final answer as: Final Answer: \\boxed{{...}}
91
- - Format all the mathematical notayions clearly every step neatly.
92
-
93
- ---
94
 
95
  Problem:
96
  {question}
97
 
98
- Context (if needed for the solution):
99
  {context}
100
 
101
- Write the solution in full below:
102
  """
103
 
104
 
105
 
 
106
  try:
107
  model = genai.GenerativeModel('gemini-2.0-flash') # or use 'gemini-1.5-flash'
108
  response = model.generate_content(prompt)
 
81
  return {"answer": "", "retrieved_context": ""}
82
 
83
  prompt = f"""
84
+ You are a math textbook author. Write a clear, professional, and well-formatted solution for the following math problem, using proper LaTeX formatting in every step.
85
 
86
+ Instructions:
87
+ - Use step-by-step headings: "Step 1", "Step 2", etc.
88
+ - Format all mathematical expressions in LaTeX (inside $$ for block or \\( ... \\) for inline).
89
+ - Avoid repeating the same math in plain text (e.g., don't write both "2t = y + 1" and "2t=y+1").
90
+ - Use aligned LaTeX equations for clarity where necessary.
91
+ - End with the final boxed answer in LaTeX like: \\boxed{{...}}
 
 
92
 
93
  Problem:
94
  {question}
95
 
96
+ Use the following context if needed:
97
  {context}
98
 
99
+ Write only the formatted solution, as it would appear in a math textbook.
100
  """
101
 
102
 
103
 
104
+
105
  try:
106
  model = genai.GenerativeModel('gemini-2.0-flash') # or use 'gemini-1.5-flash'
107
  response = model.generate_content(prompt)