File size: 578 Bytes
ebd70cc
2d420ee
ebd70cc
2d420ee
ebd70cc
2d420ee
 
 
 
 
 
 
 
 
 
 
 
 
ebd70cc
2d420ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import wolframalpha

app = gr.App(title="Math Teacher", description="A simple math teacher that can help you solve math problems.")

@app.callback(
    output="text",
    inputs="text",
)
def solve_math_problem(math_problem):
    """Solve a math problem using Wolfram Alpha."""
    app_id = "" # Your Wolfram Alpha App ID token here
    client = wolframalpha.Client(app_id)
    try:
        result = client.query(math_problem)
        return result.pods[0].text
    except Exception:
        return "Sorry, I couldn't solve your math problem."

app.launch()