Update app.py
Browse files
app.py
CHANGED
|
@@ -105,8 +105,16 @@ def set_visible_false():
|
|
| 105 |
def set_visible_true():
|
| 106 |
return gr.update(visible=True)
|
| 107 |
|
| 108 |
-
title = """<h1 align="center">🔥
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
#Modifying existing Gradio Theme
|
| 112 |
theme = gr.themes.Soft(primary_hue="zinc", secondary_hue="green", neutral_hue="green",
|
|
@@ -115,20 +123,23 @@ theme = gr.themes.Soft(primary_hue="zinc", secondary_hue="green", neutral_hue="g
|
|
| 115 |
with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""",
|
| 116 |
theme=theme) as demo:
|
| 117 |
gr.HTML(title)
|
| 118 |
-
|
|
|
|
|
|
|
| 119 |
|
| 120 |
with gr.Column(elem_id = "col_container"):
|
| 121 |
#GPT4 API Key is provided by Huggingface
|
| 122 |
with gr.Accordion(label="System message:", open=False):
|
| 123 |
-
system_msg = gr.Textbox(label="
|
|
|
|
| 124 |
chatbot = gr.Chatbot(label='GPT4', elem_id="chatbot")
|
| 125 |
-
inputs = gr.Textbox(placeholder= "
|
| 126 |
state = gr.State([])
|
| 127 |
with gr.Row():
|
| 128 |
with gr.Column(scale=7):
|
| 129 |
b1 = gr.Button().style(full_width=True)
|
| 130 |
with gr.Column(scale=3):
|
| 131 |
-
server_status_code = gr.Textbox(label="
|
| 132 |
|
| 133 |
#top_p, temperature
|
| 134 |
with gr.Accordion("Parameters", open=False):
|
|
@@ -147,7 +158,6 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
| 147 |
|
| 148 |
b1.click(reset_textbox, [], [inputs])
|
| 149 |
inputs.submit(reset_textbox, [], [inputs])
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
demo.queue(max_size=99, concurrency_count=20).launch(debug=True)
|
|
|
|
| 105 |
def set_visible_true():
|
| 106 |
return gr.update(visible=True)
|
| 107 |
|
| 108 |
+
title = """<h1 align="center">🔥GPT4 with ChatCompletions API +🚀Gradio-Streaming</h1>"""
|
| 109 |
|
| 110 |
+
#display message for themes feature
|
| 111 |
+
theme_addon_msg = """<center>🌟 Discover Gradio Themes with this Demo, featuring v3.22.0! Gradio v3.23.0 also enables seamless Theme sharing. You can develop or modify a theme, and send it to the hub using simple <code>theme.push_to_hub()</code>.
|
| 112 |
+
<br>🏆Participate in Gradio's Theme Building Hackathon to exhibit your creative flair and win fabulous rewards! Join here - <a href="https://huggingface.co/Gradio-Themes" target="_blank">Gradio-Themes-Party🎨</a> 🏆</center>
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
#Using info to add additional information about System message in GPT4
|
| 116 |
+
system_msg_info = """A conversation could begin with a system message to gently instruct the assistant.
|
| 117 |
+
System message helps set the behavior of the AI Assistant. For example, the assistant could be instructed with 'You are a helpful assistant.'"""
|
| 118 |
|
| 119 |
#Modifying existing Gradio Theme
|
| 120 |
theme = gr.themes.Soft(primary_hue="zinc", secondary_hue="green", neutral_hue="green",
|
|
|
|
| 123 |
with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""",
|
| 124 |
theme=theme) as demo:
|
| 125 |
gr.HTML(title)
|
| 126 |
+
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>""")
|
| 127 |
+
gr.HTML(theme_addon_msg)
|
| 128 |
+
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>''')
|
| 129 |
|
| 130 |
with gr.Column(elem_id = "col_container"):
|
| 131 |
#GPT4 API Key is provided by Huggingface
|
| 132 |
with gr.Accordion(label="System message:", open=False):
|
| 133 |
+
system_msg = gr.Textbox(label="Instruct the AI Assistant to set its beaviour", info = system_msg_info, value="")
|
| 134 |
+
accordion_msg = gr.HTML(value="🚧 To set System message you will have to refresh the app", visible=False)
|
| 135 |
chatbot = gr.Chatbot(label='GPT4', elem_id="chatbot")
|
| 136 |
+
inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter")
|
| 137 |
state = gr.State([])
|
| 138 |
with gr.Row():
|
| 139 |
with gr.Column(scale=7):
|
| 140 |
b1 = gr.Button().style(full_width=True)
|
| 141 |
with gr.Column(scale=3):
|
| 142 |
+
server_status_code = gr.Textbox(label="Status code from OpenAI server", )
|
| 143 |
|
| 144 |
#top_p, temperature
|
| 145 |
with gr.Accordion("Parameters", open=False):
|
|
|
|
| 158 |
|
| 159 |
b1.click(reset_textbox, [], [inputs])
|
| 160 |
inputs.submit(reset_textbox, [], [inputs])
|
| 161 |
+
|
|
|
|
| 162 |
|
| 163 |
demo.queue(max_size=99, concurrency_count=20).launch(debug=True)
|