MasteredUltraInstinct commited on
Commit
c6ab1d9
Β·
verified Β·
1 Parent(s): 7b2126f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -2,15 +2,35 @@ import gradio as gr
2
  import matplotlib
3
  matplotlib.use('Agg') # Set Agg backend to avoid Qt issues
4
  import matplotlib.pyplot as plt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  from polynomial import polynomial_tab
6
  from linear import linear_tab
7
  from image import image_tab
8
 
9
  with gr.Blocks(title="Polynomial and Linear System Solver") as demo:
10
- # Create all tabs
11
- poly_components = polynomial_tab()
12
- linear_components = linear_tab()
13
- image_components = image_tab()
14
 
15
  if __name__ == "__main__":
16
- demo.launch() # Removed server_port=7860 to allow automatic port selection
 
2
  import matplotlib
3
  matplotlib.use('Agg') # Set Agg backend to avoid Qt issues
4
  import matplotlib.pyplot as plt
5
+
6
+ # βœ… LLM microservice integration
7
+ import requests
8
+ from llm_utils import build_prompt # Already in your repo
9
+
10
+ EXPLAIN_API_URL = "http://<your-colab-url>/explain" # πŸ” Replace this with your real URL
11
+
12
+ def explain_with_llm(latex_str):
13
+ if not latex_str.strip():
14
+ return "⚠️ No LaTeX input provided."
15
+ prompt = build_prompt(latex_str)
16
+ try:
17
+ response = requests.post(EXPLAIN_API_URL, json={"latex": prompt})
18
+ if response.status_code == 200:
19
+ return response.json().get("explanation", "No explanation returned.")
20
+ else:
21
+ return f"❌ Error: {response.status_code} - {response.text}"
22
+ except Exception as e:
23
+ return f"❌ Exception: {e}"
24
+
25
+ # Import UI tabs
26
  from polynomial import polynomial_tab
27
  from linear import linear_tab
28
  from image import image_tab
29
 
30
  with gr.Blocks(title="Polynomial and Linear System Solver") as demo:
31
+ poly_components = polynomial_tab(explain_with_llm) # βœ… Pass function
32
+ linear_components = linear_tab(explain_with_llm) # βœ… Pass function
33
+ image_components = image_tab(explain_with_llm) # βœ… Pass function
 
34
 
35
  if __name__ == "__main__":
36
+ demo.launch()