ryanrwatkins commited on
Commit
a7325ef
β€’
1 Parent(s): ca0d588

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -111,23 +111,23 @@ with gr.Blocks(css=css) as demo:
111
  total_tokens_str = gr.Markdown(elem_id="total_tokens_str")
112
  btn_clear_conversation = gr.Button("πŸ”ƒ Start New Conversation")
113
  with gr.Column():
114
- gr.Markdown("Enter your OpenAI API Key. You can get one [here](https://platform.openai.com/account/api-keys).", elem_id="label")
115
- user_token = gr.Textbox(value='', placeholder="OpenAI API Key", type="password", show_label=False)
116
  prompt_template = gr.Dropdown(label="Choose a guru:", choices=list(prompt_templates.keys()))
117
  prompt_template_preview = gr.Markdown(elem_id="prompt_template_preview")
118
  with gr.Accordion("Advanced parameters", open=False):
119
  temperature = gr.Slider(minimum=0, maximum=2.0, value=0.7, step=0.1, label="Flexibility", info="Higher = more creative/chaotic, Lower = just the guru")
120
  max_tokens = gr.Slider(minimum=100, maximum=400, value=400, step=1, label="Max tokens per response")
121
- context_length = gr.Slider(minimum=1, maximum=10, value=2, step=1, label="Context length", info="Number of previous questions you have asked. Be careful with high values, it can blow up the token budget quickly.")
122
 
123
  gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/anzorq/chatgpt-demo?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
124
  <p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.chatgpt_api_demo_hf" alt="visitors"></p></center>''')
125
 
126
- btn_submit.click(submit_message, [user_token, input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
127
- input_message.submit(submit_message, [user_token, input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
128
  btn_clear_conversation.click(clear_conversation, [], [input_message, chatbot, total_tokens_str, state])
129
  prompt_template.change(on_prompt_template_change, inputs=[prompt_template], outputs=[prompt_template_preview])
130
- user_token.change(on_token_change, inputs=[user_token], outputs=[])
131
 
132
 
133
  demo.load(download_prompt_templates, inputs=None, outputs=[prompt_template], queur=False)
 
111
  total_tokens_str = gr.Markdown(elem_id="total_tokens_str")
112
  btn_clear_conversation = gr.Button("πŸ”ƒ Start New Conversation")
113
  with gr.Column():
114
+ #gr.Markdown("Enter your OpenAI API Key. You can get one [here](https://platform.openai.com/account/api-keys).", elem_id="label")
115
+ #user_token = gr.Textbox(value='', placeholder="OpenAI API Key", type="password", show_label=False)
116
  prompt_template = gr.Dropdown(label="Choose a guru:", choices=list(prompt_templates.keys()))
117
  prompt_template_preview = gr.Markdown(elem_id="prompt_template_preview")
118
  with gr.Accordion("Advanced parameters", open=False):
119
  temperature = gr.Slider(minimum=0, maximum=2.0, value=0.7, step=0.1, label="Flexibility", info="Higher = more creative/chaotic, Lower = just the guru")
120
  max_tokens = gr.Slider(minimum=100, maximum=400, value=400, step=1, label="Max tokens per response")
121
+ context_length = gr.Slider(minimum=1, maximum=5, value=2, step=1, label="Context length", info="Number of previous questions you have asked. Be careful with high values, it can blow up the token budget quickly.")
122
 
123
  gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/anzorq/chatgpt-demo?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
124
  <p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.chatgpt_api_demo_hf" alt="visitors"></p></center>''')
125
 
126
+ btn_submit.click(submit_message, [input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
127
+ input_message.submit(submit_message, [input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
128
  btn_clear_conversation.click(clear_conversation, [], [input_message, chatbot, total_tokens_str, state])
129
  prompt_template.change(on_prompt_template_change, inputs=[prompt_template], outputs=[prompt_template_preview])
130
+ #user_token.change(on_token_change, inputs=[user_token], outputs=[])
131
 
132
 
133
  demo.load(download_prompt_templates, inputs=None, outputs=[prompt_template], queur=False)