Commit
·
ab50d62
1
Parent(s):
fafd17b
Update app.py
Browse files
app.py
CHANGED
@@ -4,49 +4,26 @@ import sys
|
|
4 |
import json
|
5 |
import requests
|
6 |
|
7 |
-
|
8 |
-
#chatbot {height: 520px; overflow: auto;}""") as demo:
|
9 |
-
|
10 |
-
#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>''')
|
11 |
-
with gr.Column(elem_id = "col_container", visible=False) as main_block:
|
12 |
-
#GPT4 API Key is provided by Huggingface
|
13 |
-
#openai_api_key = gr.Textbox(type='password', label="Enter only your GPT4 OpenAI API key here")
|
14 |
-
chatbot = gr.Chatbot(elem_id='chatbot') #c
|
15 |
-
inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
|
16 |
-
state = gr.State([]) #s
|
17 |
-
with gr.Row():
|
18 |
-
with gr.Column(scale=7):
|
19 |
-
b1 = gr.Button().style(full_width=True)
|
20 |
-
with gr.Column(scale=3):
|
21 |
-
server_status_code = gr.Textbox(label="Status code from OpenAI server", )
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
with gr.Column(elem_id = "user_consent_container") as user_consent_block:
|
26 |
-
accept_checkbox = gr.Checkbox(visible=False)
|
27 |
-
js = "(x) => confirm('I understand that my data may be published or shared.')"
|
28 |
-
# Get user consent
|
29 |
-
with gr.Accordion("User Consent for Data Collection, Use, and Sharing", open=True):
|
30 |
-
gr.HTML("""
|
31 |
-
<div>
|
32 |
-
<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>
|
33 |
-
<ol>
|
34 |
-
<li><strong>Collection:</strong> We may collect information, including the inputs you type into our app, the outputs generated by OpenAI's API, and certain technical details about your device and connection (such as browser type, operating system, and IP address) provided by your device's request headers.</li>
|
35 |
-
<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, and for security purposes, such as protecting against unauthorized access and attacks.</li>
|
36 |
-
<li><strong>Sharing and Publication:</strong> Your data, including the technical details collected from your device's request headers, may be published, shared with third parties, or used for analysis and reporting purposes.</li>
|
37 |
-
<li><strong>Data Retention:</strong> We may retain your data, including the technical details collected from your device's request headers, for as long as necessary.</li>
|
38 |
-
</ol>
|
39 |
-
<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>
|
40 |
-
</div>
|
41 |
-
""")
|
42 |
-
accept_button = gr.Button("I Agree")
|
43 |
|
44 |
-
|
45 |
-
return user_consent_block.update(visible=False), main_block.update(visible=True)
|
46 |
|
47 |
-
#accept_button.click(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
|
48 |
-
accept_button.click(None, None, accept_checkbox, _js=js, queue=False)
|
49 |
-
accept_checkbox.change(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
4 |
import json
|
5 |
import requests
|
6 |
|
7 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
js = "(x) => confirm('Are you sure?')"
|
|
|
10 |
|
|
|
|
|
|
|
11 |
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
btn = gr.Button()
|
15 |
+
hidden_checkbox = gr.Checkbox(visible=False)
|
16 |
+
textbox = gr.Textbox()
|
17 |
+
num = gr.Number()
|
18 |
+
|
19 |
+
def hidden_checkbox_fn(checkbox_state, number):
|
20 |
+
if checkbox_state:
|
21 |
+
number += 1
|
22 |
+
display = f'confirmed {number} times'
|
23 |
+
return False, number, display
|
24 |
+
|
25 |
+
|
26 |
+
btn.click(None, None, hidden_checkbox, _js=js)
|
27 |
+
hidden_checkbox.change(hidden_checkbox_fn, [hidden_checkbox, num], [hidden_checkbox, textbox, num])
|
28 |
|
29 |
+
demo.launch()
|