yuntian-deng
commited on
Commit
•
56d3094
1
Parent(s):
ba091cb
Update app.py
Browse files
app.py
CHANGED
@@ -125,7 +125,7 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
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('''<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>''')
|
128 |
-
with gr.Column(elem_id = "col_container"):
|
129 |
#GPT4 API Key is provided by Huggingface
|
130 |
#openai_api_key = gr.Textbox(type='password', label="Enter only your GPT4 OpenAI API key here")
|
131 |
chatbot = gr.Chatbot(elem_id='chatbot') #c
|
@@ -144,31 +144,32 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
144 |
#top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
145 |
#repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
146 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
160 |
|
161 |
def enable_inputs():
|
162 |
-
|
163 |
-
inputs.set_disabled(False)
|
164 |
-
b1.set_disabled(False)
|
165 |
|
166 |
-
|
167 |
|
168 |
inputs.submit( predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code],) #openai_api_key
|
169 |
b1.click( predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code],) #openai_api_key
|
170 |
b1.click(reset_textbox, [], [inputs])
|
171 |
inputs.submit(reset_textbox, [], [inputs])
|
172 |
|
173 |
-
|
174 |
-
demo.queue(max_size=20, concurrency_count=10).launch()
|
|
|
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('''<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>''')
|
128 |
+
with gr.Column(elem_id = "col_container", visible=False) as main_block:
|
129 |
#GPT4 API Key is provided by Huggingface
|
130 |
#openai_api_key = gr.Textbox(type='password', label="Enter only your GPT4 OpenAI API key here")
|
131 |
chatbot = gr.Chatbot(elem_id='chatbot') #c
|
|
|
144 |
#top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
145 |
#repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
146 |
chat_counter = gr.Number(value=0, visible=False, precision=0)
|
147 |
+
|
148 |
+
with gr.Column(elem_id = "user_consent_container") as user_consent_block:
|
149 |
+
# Get user consent
|
150 |
+
with gr.Accordion("User Consent for Data Collection, Use, and Sharing", open=True):
|
151 |
+
gr.HTML("""
|
152 |
+
<div>
|
153 |
+
<p>By using our app, which is powered by OpenAI's API, you acknowledge and agree to the following terms regarding the data you provide:</p>
|
154 |
+
<ol>
|
155 |
+
<li><strong>Collection:</strong> We may collect information, including the inputs you type into our app and the outputs generated by OpenAI's API.</li>
|
156 |
+
<li><strong>Use:</strong> We may use the collected data for research purposes, to improve our services, and to develop new products or services, including commercial applications.</li>
|
157 |
+
<li><strong>Sharing and Publication:</strong> Your data may be published, shared with third parties, or used for analysis and reporting purposes.</li>
|
158 |
+
<li><strong>Data Retention:</strong> We may retain your data for as long as necessary.</li>
|
159 |
+
</ol>
|
160 |
+
<p>By continuing to use our app, you provide your explicit consent to the collection, use, and potential sharing of your data as described above. If you do not agree with our data collection, use, and sharing practices, please do not use our app.</p>
|
161 |
+
</div>
|
162 |
+
""")
|
163 |
+
accept_button = gr.Button("I Agree")
|
164 |
|
165 |
def enable_inputs():
|
166 |
+
return user_consent_block.update(visible=False), main_block.update(visible=True)
|
|
|
|
|
167 |
|
168 |
+
accept_button.click(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block])
|
169 |
|
170 |
inputs.submit( predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code],) #openai_api_key
|
171 |
b1.click( predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code],) #openai_api_key
|
172 |
b1.click(reset_textbox, [], [inputs])
|
173 |
inputs.submit(reset_textbox, [], [inputs])
|
174 |
|
175 |
+
demo.queue(max_size=20, concurrency_count=10).launch()
|
|