Spaces:
Sleeping
Sleeping
Download app.py from DGRDN/ALgebraBot: direct link, hf CLI and curl.
- Browser
- Download file 852 Bytes
-
https://huggingface.co/spaces/DGRDN/ALgebraBot/resolve/main/app.py
- Command line
-
hf download hf://spaces/DGRDN/ALgebraBot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DGRDN/ALgebraBot/resolve/main/app.py
852 Bytes
| import gradio as gr | |
| from sympy import symbols, Eq, solve | |
| x, y = symbols('x y') | |
| def solve_system(eq1_str, eq2_str): | |
| try: | |
| # Evaluate the equations safely | |
| eq1 = eval(eq1_str) | |
| eq2 = eval(eq2_str) | |
| solution = solve((eq1, eq2), (x, y)) | |
| if not solution: | |
| return "❌ No solution found. Check your equations." | |
| return f"✅ Solution:\nx = {solution[x]}\ny = {solution[y]}" | |
| except Exception as e: | |
| return f"⚠️ Error: {str(e)}" | |
| demo = gr.Interface( | |
| fn=solve_system, | |
| inputs=[ | |
| gr.Textbox(label="Equation 1 (e.g., Eq(2*x + 3*y, 12))"), | |
| gr.Textbox(label="Equation 2 (e.g., Eq(x - y, 3))") | |
| ], | |
| outputs="text", | |
| title="🧮 Two-Variable Algebra Solver", | |
| description="Enter two equations using SymPy syntax. Example: Eq(2*x + 3*y, 12)" | |
| ) | |
| demo.launch() |