Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,10 @@ if os.path.exists(".env"):
|
|
10 |
|
11 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
12 |
|
|
|
|
|
|
|
|
|
13 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
14 |
|
15 |
def respond(user_message, history):
|
@@ -37,7 +41,7 @@ def respond(user_message, history):
|
|
37 |
|
38 |
return "", history
|
39 |
|
40 |
-
# ✅ Ensure
|
41 |
with gr.Blocks() as demo:
|
42 |
gr.Markdown("# AI-Guided Math PD Chatbot")
|
43 |
|
@@ -56,15 +60,5 @@ with gr.Blocks() as demo:
|
|
56 |
outputs=[state_history]
|
57 |
)
|
58 |
|
59 |
-
gr.Markdown(
|
60 |
-
"""
|
61 |
-
<script>
|
62 |
-
MathJax = {
|
63 |
-
tex: { inlineMath: [['$', '$'], ['\\(', '\\)']], displayMath: [['$$', '$$']] }
|
64 |
-
};
|
65 |
-
</script>
|
66 |
-
"""
|
67 |
-
)
|
68 |
-
|
69 |
if __name__ == "__main__":
|
70 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
10 |
|
11 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
12 |
|
13 |
+
# ✅ Ensure OpenAI API Key Exists
|
14 |
+
if not OPENAI_API_KEY:
|
15 |
+
raise ValueError("Missing OpenAI API Key! Make sure .env file contains OPENAI_API_KEY.")
|
16 |
+
|
17 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
18 |
|
19 |
def respond(user_message, history):
|
|
|
41 |
|
42 |
return "", history
|
43 |
|
44 |
+
# ✅ Ensure Gradio UI Loads
|
45 |
with gr.Blocks() as demo:
|
46 |
gr.Markdown("# AI-Guided Math PD Chatbot")
|
47 |
|
|
|
60 |
outputs=[state_history]
|
61 |
)
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if __name__ == "__main__":
|
64 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|