yuntian-deng commited on
Commit
afc6515
1 Parent(s): 44a7379

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -3,13 +3,14 @@ import os
3
  import sys
4
  import json
5
  import requests
 
6
 
7
  MODEL = "o1-preview"
8
  API_URL = os.getenv("API_URL")
9
  DISABLED = os.getenv("DISABLED") == 'True'
10
- OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
11
  print (API_URL)
12
- print (OPENAI_API_KEY)
13
  NUM_THREADS = int(os.getenv("NUM_THREADS"))
14
 
15
  print (NUM_THREADS)
@@ -47,7 +48,7 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot, history, request:
47
 
48
  headers = {
49
  "Content-Type": "application/json",
50
- "Authorization": f"Bearer {OPENAI_API_KEY}",
51
  "Headers": f"{request.kwargs['headers']}"
52
  }
53
 
@@ -121,7 +122,7 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot, history, request:
121
  def reset_textbox():
122
  return gr.update(value='', interactive=False), gr.update(interactive=False)
123
 
124
- title = """<h1 align="center">GPT-4O: Research Preview (128K token limit, Short-Term Availability)</h1>"""
125
  if DISABLED:
126
  title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. Please check back tomorrow.</h1>"""
127
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
@@ -141,9 +142,7 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
141
  #chatbot {height: 520px; overflow: auto;}""",
142
  theme=theme) as demo:
143
  gr.HTML(title)
144
- #gr.HTML("""<h3 align="center">This app provides you full access to GPT-4O (128K token limit). You don't need any OPENAI API key.</h1>""")
145
- #gr.HTML("""<h3 align="center" style="color: red;">If this app is too busy, consider trying our other GPT-4O app. Visit it below:<br/><a href="https://huggingface.co/spaces/yuntian-deng/ChatGPT4Turbo">https://huggingface.co/spaces/yuntian-deng/ChatGPT4Turbo</a></h3>""")
146
- gr.HTML("""<h3 align="center" style="color: red;">If this app doesn't respond, consider trying our other GPT-4O app:<br/><a href="https://huggingface.co/spaces/yuntian-deng/ChatGPT4Turbo">https://huggingface.co/spaces/yuntian-deng/ChatGPT4Turbo</a></h3>""")
147
 
148
  #gr.HTML('''<center><a href="https://huggingface.co/spaces/ysharma/ChatGPT4?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>''')
149
  with gr.Column(elem_id = "col_container", visible=False) as main_block:
 
3
  import sys
4
  import json
5
  import requests
6
+ import random
7
 
8
  MODEL = "o1-preview"
9
  API_URL = os.getenv("API_URL")
10
  DISABLED = os.getenv("DISABLED") == 'True'
11
+ OPENAI_API_KEYS = os.getenv("OPENAI_API_KEYs").split(',')
12
  print (API_URL)
13
+ print (OPENAI_API_KEYs)
14
  NUM_THREADS = int(os.getenv("NUM_THREADS"))
15
 
16
  print (NUM_THREADS)
 
48
 
49
  headers = {
50
  "Content-Type": "application/json",
51
+ "Authorization": f"Bearer {random.choice(OPENAI_API_KEYS)}",
52
  "Headers": f"{request.kwargs['headers']}"
53
  }
54
 
 
122
  def reset_textbox():
123
  return gr.update(value='', interactive=False), gr.update(interactive=False)
124
 
125
+ title = """<h1 align="center">GPT-O1-Preview: Research Preview (Short-Term Availability)</h1>"""
126
  if DISABLED:
127
  title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. Please check back tomorrow.</h1>"""
128
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
 
142
  #chatbot {height: 520px; overflow: auto;}""",
143
  theme=theme) as demo:
144
  gr.HTML(title)
145
+ gr.HTML("""<h3 align="center" style="color: red;">If this app doesn't respond, consider trying our O1-mini app:<br/><a href="https://huggingface.co/spaces/yuntian-deng/ChatGPTo1mini">https://huggingface.co/spaces/yuntian-deng/ChatGPTo1mini</a></h3>""")
 
 
146
 
147
  #gr.HTML('''<center><a href="https://huggingface.co/spaces/ysharma/ChatGPT4?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>''')
148
  with gr.Column(elem_id = "col_container", visible=False) as main_block: