Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
| 4 |
-
from prompts.main_prompt import MAIN_PROMPT # β
|
|
|
|
| 5 |
|
| 6 |
# β
Ensure OpenAI API Key is Set (Use Secrets in Hugging Face)
|
| 7 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
@@ -40,8 +41,12 @@ def respond(user_message, history):
|
|
| 40 |
with gr.Blocks() as demo:
|
| 41 |
gr.Markdown("# **AI-Guided Math PD Chatbot**")
|
| 42 |
|
| 43 |
-
chatbot = gr.Chatbot(
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
user_input = gr.Textbox(placeholder="Type your message here...", label="Your Input")
|
| 47 |
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
| 4 |
+
from prompts.main_prompt import MAIN_PROMPT # β
Fix Import Path
|
| 5 |
+
from prompts.initial_prompt import INITIAL_PROMPT # β
Ensure Initial Prompt is Included
|
| 6 |
|
| 7 |
# β
Ensure OpenAI API Key is Set (Use Secrets in Hugging Face)
|
| 8 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
gr.Markdown("# **AI-Guided Math PD Chatbot**")
|
| 43 |
|
| 44 |
+
chatbot = gr.Chatbot(
|
| 45 |
+
value=[("", INITIAL_PROMPT)], # β
Shows Initial Prompt on Startup
|
| 46 |
+
height=500
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
state_history = gr.State([("", INITIAL_PROMPT)]) # β
Ensures History Starts with Initial Prompt
|
| 50 |
|
| 51 |
user_input = gr.Textbox(placeholder="Type your message here...", label="Your Input")
|
| 52 |
|