MasteredUltraInstinct commited on
Commit
68fae68
·
verified ·
1 Parent(s): a762d4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -119,7 +119,7 @@ def solve_polynomial(image, llm_url):
119
  root_strs.append(str(root_val))
120
  output += "\\end{aligned}\n$$\n"
121
 
122
- # 🔍 Build structured LLM prompt
123
  prompt = ""
124
  try:
125
  coeffs = sp.Poly(lhs, x).all_coeffs()
@@ -137,10 +137,10 @@ def solve_polynomial(image, llm_url):
137
  f"Equation: {lhs} = 0\n"
138
  f"Factor: {factor} = 0\n"
139
  f"Roots: {root_strs}\n\n"
140
- f"Middle-term factorization used: "
141
  f"a = {a}, b = {b}, c = {c}, a*c = {prod}. "
142
  f"{m} and {n} satisfy m*n = ac and m+n = b.\n"
143
- f"Explain clearly, step-by-step.\n<|end|>"
144
  )
145
  break
146
  if not found:
@@ -152,9 +152,8 @@ def solve_polynomial(image, llm_url):
152
  f"Equation: {lhs} = 0\n"
153
  f"Factor: {factor} = 0\n"
154
  f"Roots: {root_strs}\n\n"
155
- f"Middle-term factorization was not suitable.\n"
156
- f"Used Sreedhar Acharya quadratic formula instead.\n"
157
- f"Explain this step-by-step.\n<|end|>"
158
  )
159
 
160
  return output, cleaned_latex, prompt
@@ -197,7 +196,8 @@ def solve_from_coeffs(degree, coeff_str):
197
  f"Equation: {equation_str}\n"
198
  f"Factor: {factored_str} = 0\n"
199
  f"Roots: {roots_str}\n\n"
200
- f"Explain the above solution in simple steps.\n<|end|>"
 
201
  )
202
 
203
  return result, llm_prompt
 
119
  root_strs.append(str(root_val))
120
  output += "\\end{aligned}\n$$\n"
121
 
122
+ # 👇 Build structured prompt
123
  prompt = ""
124
  try:
125
  coeffs = sp.Poly(lhs, x).all_coeffs()
 
137
  f"Equation: {lhs} = 0\n"
138
  f"Factor: {factor} = 0\n"
139
  f"Roots: {root_strs}\n\n"
140
+ f"This was solved using middle-term factorization:\n"
141
  f"a = {a}, b = {b}, c = {c}, a*c = {prod}. "
142
  f"{m} and {n} satisfy m*n = ac and m+n = b.\n"
143
+ f"Explain the process step-by-step in friendly, simple language."
144
  )
145
  break
146
  if not found:
 
152
  f"Equation: {lhs} = 0\n"
153
  f"Factor: {factor} = 0\n"
154
  f"Roots: {root_strs}\n\n"
155
+ f"This was solved using the quadratic formula (Sreedhar Acharya method). "
156
+ f"Explain the process step-by-step in friendly, simple language."
 
157
  )
158
 
159
  return output, cleaned_latex, prompt
 
196
  f"Equation: {equation_str}\n"
197
  f"Factor: {factored_str} = 0\n"
198
  f"Roots: {roots_str}\n\n"
199
+ "Explain the solution step-by-step in human language. "
200
+ "These roots are correct (up to approximation), so base your reasoning on them."
201
  )
202
 
203
  return result, llm_prompt