jackycedar commited on
Commit
bbf9b62
·
1 Parent(s): 84bd880

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -476,32 +476,32 @@ with gr.Blocks() as demo:
476
  answer2 = gr.Textbox(label="Answer")
477
  b2.click(qa2, inputs=[question2,radio2], outputs=answer2)
478
 
479
- # with gr.Tab("Reserved"):
480
- # with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
481
- # #chatbot {height: 520px; overflow: auto;}""",
482
- # theme=theme) as demo:
483
- # gr.HTML(title)
484
- # 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>""")
485
- # #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>''')
486
- # with gr.Column(elem_id = "col_container", visible=False) as main_block:
487
- # #API Key is provided by OpenAI
488
- # #openai_api_key = gr.Textbox(type='password', label="Enter only your OpenAI API key here")
489
- # chatbot = gr.Chatbot(elem_id='chatbot') #c
490
- # inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
491
- # state = gr.State([]) #s
492
- # with gr.Row():
493
- # with gr.Column(scale=7):
494
- # b1 = gr.Button(visible=not DISABLED).style(full_width=True)
495
- # with gr.Column(scale=3):
496
- # server_status_code = gr.Textbox(label="Status code from OpenAI server", )
497
 
498
- # #inputs, top_p, temperature, top_k, repetition_penalty
499
- # with gr.Accordion("Parameters", open=False):
500
- # top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
501
- # temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
502
- # #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
503
- # #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
504
- # chat_counter = gr.Number(value=0, visible=False, precision=0)
505
 
506
  # with gr.Column(elem_id = "user_consent_container") as user_consent_block:
507
  # # Get user consent
@@ -525,10 +525,10 @@ with gr.Blocks() as demo:
525
 
526
  # accept_button.click(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
527
 
528
- # inputs.submit(reset_textbox, [], [inputs, b1], queue=False)
529
- # inputs.submit(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
530
- # b1.click(reset_textbox, [], [inputs, b1], queue=False)
531
- # b1.click(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
532
 
533
  # demo.queue(max_size=20, concurrency_count=10, api_open=False).launch()
534
 
 
476
  answer2 = gr.Textbox(label="Answer")
477
  b2.click(qa2, inputs=[question2,radio2], outputs=answer2)
478
 
479
+ with gr.Tab("ChatGPT"):
480
+ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
481
+ #chatbot {height: 520px; overflow: auto;}""",
482
+ theme=theme) as demo:
483
+ gr.HTML(title)
484
+ 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>""")
485
+ #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>''')
486
+ with gr.Column(elem_id = "col_container", visible=True) as main_block:
487
+ #API Key is provided by OpenAI
488
+ #openai_api_key = gr.Textbox(type='password', label="Enter only your OpenAI API key here")
489
+ chatbot = gr.Chatbot(elem_id='chatbot') #c
490
+ inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
491
+ state = gr.State([]) #s
492
+ with gr.Row():
493
+ with gr.Column(scale=7):
494
+ b1 = gr.Button(visible=not DISABLED).style(full_width=True)
495
+ with gr.Column(scale=3):
496
+ server_status_code = gr.Textbox(label="Status code from OpenAI server", )
497
 
498
+ inputs, top_p, temperature, top_k, repetition_penalty
499
+ with gr.Accordion("Parameters", open=False):
500
+ top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
501
+ temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
502
+ #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
503
+ #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
504
+ chat_counter = gr.Number(value=0, visible=True, precision=0)
505
 
506
  # with gr.Column(elem_id = "user_consent_container") as user_consent_block:
507
  # # Get user consent
 
525
 
526
  # accept_button.click(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
527
 
528
+ inputs.submit(reset_textbox, [], [inputs, b1], queue=False)
529
+ inputs.submit(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
530
+ b1.click(reset_textbox, [], [inputs, b1], queue=False)
531
+ b1.click(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
532
 
533
  # demo.queue(max_size=20, concurrency_count=10, api_open=False).launch()
534