AkshitShubham commited on
Commit
8424f27
·
verified ·
1 Parent(s): bdfe297

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -39,7 +39,7 @@ def extract_equations_and_generate_commands(api_response):
39
  continue
40
 
41
  # Check if line contains LaTeX math
42
- if ('$' in line or '\\' in line) and not line.startswith('#'):
43
  # Extract LaTeX content
44
  latex_content = line
45
 
@@ -148,17 +148,16 @@ def image_to_latex(image):
148
  Instructions:
149
  - Extract each mathematical equation or formula separately
150
  - Use proper LaTeX syntax for mathematical expressions
151
- - For display math, use $$ ... $$ format
152
- - For inline math, use $ ... $ format
153
  - Put each equation on a separate line
154
  - Do not include any markdown formatting or explanatory text
155
  - Only output the raw LaTeX code for each equation
156
  - If there are multiple equations, list them one per line
157
 
158
  Example output format:
159
- $$\\frac{a}{b} = c$$
160
- $$x^2 + y^2 = z^2$$
161
- $$\\int_0^1 x dx = \\frac{1}{2}$$"""
162
  },
163
  {
164
  "inline_data": {
@@ -185,7 +184,7 @@ $$\\int_0^1 x dx = \\frac{1}{2}$$"""
185
  equations = []
186
  for line in latex_output.split('\n'):
187
  line = line.strip()
188
- if line and ('$' in line or '\\' in line):
189
  equations.append(line)
190
 
191
  if not equations:
@@ -323,8 +322,7 @@ def create_app():
323
  # Example section
324
  gr.Markdown("### 🎯 Example Output Format:")
325
  gr.Code(
326
- """maths2svg --latex "$$h = h_0 + \\frac{2\\sigma \\cos\\theta}{\\rho g r}$$" --output capillary_rise.svg""",
327
- language="bash"
328
  )
329
 
330
  # Set up the conversion action
@@ -350,7 +348,7 @@ if __name__ == "__main__":
350
  # Launch with custom settings
351
  app.launch(
352
  share=False, # Set to True if you want to create a public link
353
- server_name="127.0.0.1",
354
  server_port=7860,
355
  show_error=True
356
  )
 
39
  continue
40
 
41
  # Check if line contains LaTeX math
42
+ if '\\' in line and not line.startswith('#'):
43
  # Extract LaTeX content
44
  latex_content = line
45
 
 
148
  Instructions:
149
  - Extract each mathematical equation or formula separately
150
  - Use proper LaTeX syntax for mathematical expressions
151
+ - Output raw LaTeX without any $ delimiters
 
152
  - Put each equation on a separate line
153
  - Do not include any markdown formatting or explanatory text
154
  - Only output the raw LaTeX code for each equation
155
  - If there are multiple equations, list them one per line
156
 
157
  Example output format:
158
+ \\frac{a}{b} = c
159
+ x^2 + y^2 = z^2
160
+ \\int_0^1 x dx = \\frac{1}{2}"""
161
  },
162
  {
163
  "inline_data": {
 
184
  equations = []
185
  for line in latex_output.split('\n'):
186
  line = line.strip()
187
+ if line and '\\' in line:
188
  equations.append(line)
189
 
190
  if not equations:
 
322
  # Example section
323
  gr.Markdown("### 🎯 Example Output Format:")
324
  gr.Code(
325
+ """maths2svg --latex "h = h_0 + \\frac{2\\sigma \\cos\\theta}{\\rho g r}" --output capillary_rise.svg"""
 
326
  )
327
 
328
  # Set up the conversion action
 
348
  # Launch with custom settings
349
  app.launch(
350
  share=False, # Set to True if you want to create a public link
351
+ server_name="0.0.0.0",
352
  server_port=7860,
353
  show_error=True
354
  )