jackycedar commited on
Commit
d52bfff
·
1 Parent(s): 20cd6f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -7
app.py CHANGED
@@ -348,13 +348,62 @@ with gr.Blocks() as demo:
348
  answer2 = gr.Textbox(label="Answer")
349
  b2.click(qa2, inputs=[question2,radio2], outputs=answer2)
350
 
351
- # with gr.Tab("Reserved"):
352
- # inp3a = gr.Textbox()
353
- # inp3b = gr.Textbox()
354
- # out3 = gr.Textbox()
355
- # inp3a.change(pdfv3, [inp3a,inp3b], out3)
356
- # with gr.Accordion("Open for More!"):
357
- # gr.Markdown("Look at me...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
 
359
 
360
  if __name__ == "__main__":
 
348
  answer2 = gr.Textbox(label="Answer")
349
  b2.click(qa2, inputs=[question2,radio2], outputs=answer2)
350
 
351
+ with gr.Tab("Reserved"):
352
+ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
353
+ #chatbot {height: 520px; overflow: auto;}""",
354
+ theme=theme) as demo:
355
+ gr.HTML(title)
356
+ gr.HTML("""<h3 align="center">This app provides you full access to GPT-3.5 (4096 token limit). You don't need any OPENAI API key.</h1>""")
357
+ #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>''')
358
+ with gr.Column(elem_id = "col_container", visible=False) as main_block:
359
+ #API Key is provided by OpenAI
360
+ #openai_api_key = gr.Textbox(type='password', label="Enter only your OpenAI API key here")
361
+ chatbot = gr.Chatbot(elem_id='chatbot') #c
362
+ inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
363
+ state = gr.State([]) #s
364
+ with gr.Row():
365
+ with gr.Column(scale=7):
366
+ b1 = gr.Button(visible=not DISABLED).style(full_width=True)
367
+ with gr.Column(scale=3):
368
+ server_status_code = gr.Textbox(label="Status code from OpenAI server", )
369
+
370
+ #inputs, top_p, temperature, top_k, repetition_penalty
371
+ with gr.Accordion("Parameters", open=False):
372
+ top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
373
+ temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
374
+ #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
375
+ #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
376
+ chat_counter = gr.Number(value=0, visible=False, precision=0)
377
+
378
+ with gr.Column(elem_id = "user_consent_container") as user_consent_block:
379
+ # Get user consent
380
+ with gr.Accordion("User Consent for Data Collection, Use, and Sharing", open=True):
381
+ gr.HTML("""
382
+ <div>
383
+ <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>
384
+ <ol>
385
+ <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>
386
+ <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>
387
+ <li><strong>Sharing and Publication:</strong> Your data may be published, shared with third parties, or used for analysis and reporting purposes.</li>
388
+ <li><strong>Data Retention:</strong> We may retain your data for as long as necessary.</li>
389
+ </ol>
390
+ <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>
391
+ </div>
392
+ """)
393
+ accept_button = gr.Button("I Agree")
394
+
395
+ # def enable_inputs():
396
+ # return user_consent_block.update(visible=False), main_block.update(visible=True)
397
+
398
+ # accept_button.click(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
399
+
400
+ # inputs.submit(reset_textbox, [], [inputs, b1], queue=False)
401
+ # inputs.submit(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
402
+ # b1.click(reset_textbox, [], [inputs, b1], queue=False)
403
+ # b1.click(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
404
+
405
+ # demo.queue(max_size=20, concurrency_count=10, api_open=False).launch()
406
+
407
 
408
 
409
  if __name__ == "__main__":