Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -7,8 +7,9 @@ import openai # This allows us to connect to Poe’s API (powered by OpenAI)
7
  # 🛠️ Poe API Setup
8
  # -------------------------
9
 
10
- # We get the Poe API key from the environment (it's stored securely in Hugging Face Secrets)
11
  # This key lets us connect to Poe’s chatbot service
 
12
  POE_API_KEY = os.environ["POE_API_KEY"]
13
 
14
  # Creating a client (connection) to the Poe API
@@ -29,6 +30,11 @@ def chat_with_poe(history, message):
29
 
30
  # Convert Gradio’s format to Poe’s format
31
  messages = [] # This will be a list of messages we send to Poe
 
 
 
 
 
32
  for user_msg, bot_msg in history:
33
  # Add the user’s previous message
34
  messages.append({"role": "user", "content": user_msg})
@@ -42,7 +48,7 @@ def chat_with_poe(history, message):
42
  try:
43
  # Send the messages to Poe and get the response from the chatbot
44
  response = client.chat.completions.create(
45
- model="My_Tutor_Shq", # The name of your bot on Poe
46
  messages=messages # All past and current messages
47
  )
48
  # Extract the bot’s reply from the response
@@ -67,10 +73,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
67
 
68
  # This adds a title and description at the top
69
  gr.Markdown(
70
-
71
- # 🤖 Your title goes here
72
- # Description
73
- # Type below to start chatting.
74
  """
75
  # 🤖 Python Tutor Bot
76
  """
 
7
  # 🛠️ Poe API Setup
8
  # -------------------------
9
 
10
+ # We get the Poe API key from the environment (it's stored securely in Hugging Face Secrets or your system)
11
  # This key lets us connect to Poe’s chatbot service
12
+ # Updated API key: Set it as an environment variable (e.g., export POE_API_KEY='1M-vj81pjfDeddkHOtcovh-NZb_ltZJLNojrm_Px5oI')
13
  POE_API_KEY = os.environ["POE_API_KEY"]
14
 
15
  # Creating a client (connection) to the Poe API
 
30
 
31
  # Convert Gradio’s format to Poe’s format
32
  messages = [] # This will be a list of messages we send to Poe
33
+
34
+ # Optional: Add a system prompt at the start to guide the bot's behavior (e.g., act as a tutor)
35
+ # Uncomment and customize if you want to "change the prompt"
36
+ # messages.append({"role": "system", "content": "You are a helpful Python tutor. Explain concepts clearly and provide code examples."})
37
+
38
  for user_msg, bot_msg in history:
39
  # Add the user’s previous message
40
  messages.append({"role": "user", "content": user_msg})
 
48
  try:
49
  # Send the messages to Poe and get the response from the chatbot
50
  response = client.chat.completions.create(
51
+ model="EchoForge_20", # Updated model name (changed from "My_Tutor_Shq")
52
  messages=messages # All past and current messages
53
  )
54
  # Extract the bot’s reply from the response
 
73
 
74
  # This adds a title and description at the top
75
  gr.Markdown(
 
 
 
 
76
  """
77
  # 🤖 Python Tutor Bot
78
  """