Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
image_components = image_tab()
|
| 14 |
|
| 15 |
if __name__ == "__main__":
|
| 16 |
-
demo.launch()
|
|
|
|
| 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()
|