MasteredUltraInstinct commited on
Commit
66e7d83
Β·
verified Β·
1 Parent(s): 4241ae9

Create llm_interface.py

Browse files
Files changed (1) hide show
  1. llm_interface.py +18 -0
llm_interface.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # llm_interface.py
2
+ import requests
3
+ from llm_utils import build_prompt
4
+
5
+ EXPLAIN_API_URL = "http://<your-colab-url>/explain" # ← Replace this with your actual backend URL
6
+
7
+ def explain_with_llm(latex_str):
8
+ if not latex_str.strip():
9
+ return "⚠️ No LaTeX input provided."
10
+ prompt = build_prompt(latex_str)
11
+ try:
12
+ response = requests.post(EXPLAIN_API_URL, json={"latex": prompt})
13
+ if response.status_code == 200:
14
+ return response.json().get("explanation", "No explanation returned.")
15
+ else:
16
+ return f"❌ Error: {response.status_code} - {response.text}"
17
+ except Exception as e:
18
+ return f"❌ Exception: {e}"