Echoforge24 commited on
Commit
4292790
·
verified ·
1 Parent(s): 9397cc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -1,5 +1,4 @@
1
  # Import required libraries
2
- import os
3
  import gradio as gr
4
  from openai import OpenAI
5
 
@@ -7,12 +6,8 @@ from openai import OpenAI
7
  # 🛠️ Poe API Setup
8
  # -------------------------
9
 
10
- # Get Poe API key from Hugging Face Secrets
11
- POE_API_KEY = os.environ.get("1M-vj81pjfDeddkHOtcovh-NZb_ltZJLNojrm_Px5oIY")
12
- IndentationError: unexpected indent:
13
- raise ValueError(
14
- "POE_API_KEY is missing. Add it in HF Spaces → Settings → Secrets."
15
- )
16
  # Create Poe client (Poe uses OpenAI-compatible API)
17
  client = OpenAI(
18
  api_key=POE_API_KEY,
@@ -26,18 +21,16 @@ client = OpenAI(
26
  def chat_with_poe(history, message):
27
  messages = []
28
 
29
- # Convert Gradio history to Poe / OpenAI format
30
  for user_msg, bot_msg in history:
31
  messages.append({"role": "user", "content": user_msg})
32
  if bot_msg:
33
  messages.append({"role": "assistant", "content": bot_msg})
34
 
35
- # Add new user message
36
  messages.append({"role": "user", "content": message})
37
 
38
  try:
39
  response = client.chat.completions.create(
40
- model="EchoForge_20", # EXACT Poe bot name
41
  messages=messages
42
  )
43
  bot_reply = response.choices[0].message.content.strip()
@@ -69,3 +62,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
69
  # -------------------------
70
 
71
  demo.launch()
 
 
 
1
  # Import required libraries
 
2
  import gradio as gr
3
  from openai import OpenAI
4
 
 
6
  # 🛠️ Poe API Setup
7
  # -------------------------
8
 
9
+ POE_API_KEY = "1M-vj81pjfDeddkHOtcovh-NZb_ltZJLNojrm_Px5oIY"
10
+
 
 
 
 
11
  # Create Poe client (Poe uses OpenAI-compatible API)
12
  client = OpenAI(
13
  api_key=POE_API_KEY,
 
21
  def chat_with_poe(history, message):
22
  messages = []
23
 
 
24
  for user_msg, bot_msg in history:
25
  messages.append({"role": "user", "content": user_msg})
26
  if bot_msg:
27
  messages.append({"role": "assistant", "content": bot_msg})
28
 
 
29
  messages.append({"role": "user", "content": message})
30
 
31
  try:
32
  response = client.chat.completions.create(
33
+ model="EchoForge_20",
34
  messages=messages
35
  )
36
  bot_reply = response.choices[0].message.content.strip()
 
62
  # -------------------------
63
 
64
  demo.launch()
65
+ app-error-1.txt
66
+ Displaying app-error-1.txt.