yuntian-deng commited on
Commit
835d40f
1 Parent(s): eb3516b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -4,7 +4,8 @@ import sys
4
  import json
5
  import requests
6
 
7
- #Streaming endpoint
 
8
  API_URL = os.getenv("API_URL")
9
  DISABLED = os.getenv("DISABLED") == 'True'
10
 
@@ -34,7 +35,7 @@ def parse_codeblock(text):
34
  def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
35
 
36
  payload = {
37
- "model": "gpt-4",
38
  "messages": [{"role": "user", "content": f"{inputs}"}],
39
  "temperature" : 1.0,
40
  "top_p":1.0,
@@ -67,7 +68,7 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
67
  temp3["content"] = inputs
68
  messages.append(temp3)
69
  payload = {
70
- "model": "gpt-4",
71
  "messages": messages,
72
  "temperature" : temperature, #1.0,
73
  "top_p": top_p, #1.0,
@@ -116,7 +117,7 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
116
  def reset_textbox():
117
  return gr.update(value='')
118
 
119
- title = """<h1 align="center">🔥GPT4 with ChatCompletions API +🚀Gradio-Streaming</h1>"""
120
  if DISABLED:
121
  title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. We are currently requesting an increase in our quota. Please check back in a few days.</h1>"""
122
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
@@ -127,7 +128,7 @@ User: <utterance>
127
  Assistant: <utterance>
128
  ...
129
  ```
130
- In this app, you can explore the outputs of a gpt-4 LLM.
131
  """
132
 
133
  theme = gr.themes.Default(primary_hue="green")
@@ -136,11 +137,11 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
136
  #chatbot {height: 520px; overflow: auto;}""",
137
  theme=theme) as demo:
138
  gr.HTML(title)
139
- gr.HTML("""<h3 align="center">🔥This Huggingface Gradio Demo provides you full access to GPT4 API (4096 token limit). 🎉🥳🎉You don't need any OPENAI API key🙌</h1>""")
140
- 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>''')
141
  with gr.Column(elem_id = "col_container", visible=False) as main_block:
142
- #GPT4 API Key is provided by Huggingface
143
- #openai_api_key = gr.Textbox(type='password', label="Enter only your GPT4 OpenAI API key here")
144
  chatbot = gr.Chatbot(elem_id='chatbot') #c
145
  inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
146
  state = gr.State([]) #s
 
4
  import json
5
  import requests
6
 
7
+ #Streaming endpoint
8
+ MODEL = "gpt-3.5-turbo"
9
  API_URL = os.getenv("API_URL")
10
  DISABLED = os.getenv("DISABLED") == 'True'
11
 
 
35
  def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
36
 
37
  payload = {
38
+ "model": MODEL,
39
  "messages": [{"role": "user", "content": f"{inputs}"}],
40
  "temperature" : 1.0,
41
  "top_p":1.0,
 
68
  temp3["content"] = inputs
69
  messages.append(temp3)
70
  payload = {
71
+ "model": MODEL,
72
  "messages": messages,
73
  "temperature" : temperature, #1.0,
74
  "top_p": top_p, #1.0,
 
117
  def reset_textbox():
118
  return gr.update(value='')
119
 
120
+ title = """<h1 align="center">GPT3.5 Chatbot"""
121
  if DISABLED:
122
  title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. We are currently requesting an increase in our quota. Please check back in a few days.</h1>"""
123
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
 
128
  Assistant: <utterance>
129
  ...
130
  ```
131
+ In this app, you can explore the outputs of a gpt-3.5 LLM.
132
  """
133
 
134
  theme = gr.themes.Default(primary_hue="green")
 
137
  #chatbot {height: 520px; overflow: auto;}""",
138
  theme=theme) as demo:
139
  gr.HTML(title)
140
+ gr.HTML("""<h3 align="center">This App provides you full access to GPT3.5 API (4096 token limit). You don't need any OPENAI API key</h1>""")
141
+ gr.HTML('''<center><a href="https://huggingface.co/spaces/yuntian-deng/ChatGPT?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>''')
142
  with gr.Column(elem_id = "col_container", visible=False) as main_block:
143
+ #API Key is provided by OpenAI
144
+ #openai_api_key = gr.Textbox(type='password', label="Enter only your OpenAI API key here")
145
  chatbot = gr.Chatbot(elem_id='chatbot') #c
146
  inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
147
  state = gr.State([]) #s