MasteredUltraInstinct commited on
Commit
a762d4b
·
verified ·
1 Parent(s): 95cb2cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -85,9 +85,6 @@ def solve_polynomial(image, llm_url):
85
  lhs = expr.lhs - expr.rhs
86
  if not lhs.is_polynomial():
87
  raise ValueError("Not a polynomial")
88
- junk = {"pm", "cdot", "mathrm", "boldmath", "bar", "L"}
89
- if {str(s) for s in expr.free_symbols} & junk:
90
- raise ValueError("Junk in symbols")
91
  except:
92
  fixed_latex = request_llm_fallback(cleaned_latex, llm_url)
93
  cleaned_latex = clean_latex(fixed_latex)
@@ -140,10 +137,10 @@ def solve_polynomial(image, llm_url):
140
  f"Equation: {lhs} = 0\n"
141
  f"Factor: {factor} = 0\n"
142
  f"Roots: {root_strs}\n\n"
143
- f"Middle-term factorization is applicable: "
144
  f"a = {a}, b = {b}, c = {c}, a*c = {prod}. "
145
  f"{m} and {n} satisfy m*n = ac and m+n = b.\n"
146
- f"Explain this step-by-step in human style."
147
  )
148
  break
149
  if not found:
@@ -155,8 +152,9 @@ def solve_polynomial(image, llm_url):
155
  f"Equation: {lhs} = 0\n"
156
  f"Factor: {factor} = 0\n"
157
  f"Roots: {root_strs}\n\n"
158
- f"Middle-term factorization is not suitable. "
159
- f"Explain using quadratic formula (Sreedhar Acharya) with step-by-step clarity."
 
160
  )
161
 
162
  return output, cleaned_latex, prompt
@@ -199,9 +197,7 @@ def solve_from_coeffs(degree, coeff_str):
199
  f"Equation: {equation_str}\n"
200
  f"Factor: {factored_str} = 0\n"
201
  f"Roots: {roots_str}\n\n"
202
- "Explain the solution step-by-step in human language. Use middle-term factorization if possible, "
203
- "otherwise use the quadratic formula (Sreedhar Acharya method). "
204
- "These roots are correct (up to approximation), so base your reasoning on them."
205
  )
206
 
207
  return result, llm_prompt
 
85
  lhs = expr.lhs - expr.rhs
86
  if not lhs.is_polynomial():
87
  raise ValueError("Not a polynomial")
 
 
 
88
  except:
89
  fixed_latex = request_llm_fallback(cleaned_latex, llm_url)
90
  cleaned_latex = clean_latex(fixed_latex)
 
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
  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
  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