Spaces:
Sleeping
Sleeping
JiwenJ commited on
Commit ·
0c751f7
1
Parent(s): 821c207
gpt3.5
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ openai_gpt4_key = "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"
|
|
| 6 |
# Streaming endpoint
|
| 7 |
# os.getenv("API_URL") + "/generate_stream"
|
| 8 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
| 9 |
-
a = "sss"
|
| 10 |
# Inferenec function
|
| 11 |
|
| 12 |
|
|
@@ -28,7 +27,7 @@ def predict(openai_gpt4_key, system_msg, inputs, top_p, temperature, chat_counte
|
|
| 28 |
|
| 29 |
if chat_counter == 0:
|
| 30 |
payload = {
|
| 31 |
-
"model": "gpt-
|
| 32 |
"messages": initial_message,
|
| 33 |
"temperature": 1.0,
|
| 34 |
"top_p": 1.0,
|
|
@@ -56,7 +55,7 @@ def predict(openai_gpt4_key, system_msg, inputs, top_p, temperature, chat_counte
|
|
| 56 |
messages.append(temp)
|
| 57 |
# messages
|
| 58 |
payload = {
|
| 59 |
-
"model": "gpt-
|
| 60 |
# Of the type of [{"role": "user", "content": f"{inputs}"}],
|
| 61 |
"messages": messages,
|
| 62 |
"temperature": temperature, # 1.0,
|
|
@@ -119,7 +118,7 @@ def set_visible_true():
|
|
| 119 |
return gr.update(visible=True)
|
| 120 |
|
| 121 |
|
| 122 |
-
title = """<h1 align="center">🔥
|
| 123 |
# display message for themes feature
|
| 124 |
theme_addon_msg = """<center>🌟 This Demo also introduces you to Gradio Themes. Discover more on Gradio website using our <a href="https://gradio.app/theming-guide/" target="_blank">Themeing-Guide🎨</a>! You can develop from scratch, modify an existing Gradio theme, and share your themes with community by uploading them to huggingface-hub easily using <code>theme.push_to_hub()</code>.</center>
|
| 125 |
"""
|
|
@@ -135,9 +134,9 @@ theme = gr.themes.Soft(primary_hue="zinc", secondary_hue="green", neutral_hue="g
|
|
| 135 |
with gr.Blocks(css="""#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""",
|
| 136 |
theme=theme) as demo:
|
| 137 |
gr.HTML(title)
|
| 138 |
-
gr.HTML("""<h3 align="center">🔥This Huggingface Gradio Demo provides you access to
|
| 139 |
-
gr.HTML(theme_addon_msg)
|
| 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 |
|
| 142 |
with gr.Column(elem_id="col_container"):
|
| 143 |
# Users need to provide their own GPT4 API key, it is no longer provided by Huggingface
|
|
@@ -152,7 +151,7 @@ with gr.Blocks(css="""#col_container { margin-left: auto; margin-right: auto;} #
|
|
| 152 |
|
| 153 |
chatbot = gr.Chatbot(label='GPT4', elem_id="chatbot")
|
| 154 |
inputs = gr.Textbox(placeholder="Hi there!",
|
| 155 |
-
label="Type an input and press Enter")
|
| 156 |
state = gr.State([])
|
| 157 |
with gr.Row():
|
| 158 |
with gr.Column(scale=7):
|
|
|
|
| 6 |
# Streaming endpoint
|
| 7 |
# os.getenv("API_URL") + "/generate_stream"
|
| 8 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
|
|
|
| 9 |
# Inferenec function
|
| 10 |
|
| 11 |
|
|
|
|
| 27 |
|
| 28 |
if chat_counter == 0:
|
| 29 |
payload = {
|
| 30 |
+
"model": "gpt-3.5-turbo",
|
| 31 |
"messages": initial_message,
|
| 32 |
"temperature": 1.0,
|
| 33 |
"top_p": 1.0,
|
|
|
|
| 55 |
messages.append(temp)
|
| 56 |
# messages
|
| 57 |
payload = {
|
| 58 |
+
"model": "gpt-3.5-turbo",
|
| 59 |
# Of the type of [{"role": "user", "content": f"{inputs}"}],
|
| 60 |
"messages": messages,
|
| 61 |
"temperature": temperature, # 1.0,
|
|
|
|
| 118 |
return gr.update(visible=True)
|
| 119 |
|
| 120 |
|
| 121 |
+
title = """<h1 align="center">🔥 Large Language Models as Tools for Modeling and Coding in Operations Research</h1>"""
|
| 122 |
# display message for themes feature
|
| 123 |
theme_addon_msg = """<center>🌟 This Demo also introduces you to Gradio Themes. Discover more on Gradio website using our <a href="https://gradio.app/theming-guide/" target="_blank">Themeing-Guide🎨</a>! You can develop from scratch, modify an existing Gradio theme, and share your themes with community by uploading them to huggingface-hub easily using <code>theme.push_to_hub()</code>.</center>
|
| 124 |
"""
|
|
|
|
| 134 |
with gr.Blocks(css="""#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""",
|
| 135 |
theme=theme) as demo:
|
| 136 |
gr.HTML(title)
|
| 137 |
+
gr.HTML("""<h3 align="center">🔥This Huggingface Gradio Demo provides you access to different optimiaztion scenarios. Please note that you would be needing an OPENAI API key for GPT4 access🙌</h1>""")
|
| 138 |
+
# gr.HTML(theme_addon_msg)
|
| 139 |
+
# 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>''')
|
| 140 |
|
| 141 |
with gr.Column(elem_id="col_container"):
|
| 142 |
# Users need to provide their own GPT4 API key, it is no longer provided by Huggingface
|
|
|
|
| 151 |
|
| 152 |
chatbot = gr.Chatbot(label='GPT4', elem_id="chatbot")
|
| 153 |
inputs = gr.Textbox(placeholder="Hi there!",
|
| 154 |
+
label="Type an optimization problem as input and press Enter")
|
| 155 |
state = gr.State([])
|
| 156 |
with gr.Row():
|
| 157 |
with gr.Column(scale=7):
|