chansung commited on
Commit
104164a
·
1 Parent(s): 7851c38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -152,7 +152,7 @@ def reset_chat(idx, ld, state, palm_if):
152
 
153
  async def chat_stream(
154
  idx, local_data, instruction_txtbox, chat_state,
155
- global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
156
  internet_option, serper_api_key, palm_if
157
  ):
158
  internet_option = True if internet_option == "on" else False
@@ -171,9 +171,17 @@ async def chat_stream(
171
  # search_prompt = tmp_prompt
172
  # yield "", prompt, uis, str(res), gr.update(interactive=False), "off"
173
 
 
 
 
 
 
 
 
 
174
  palm_if, response_txt = gen_text(
175
  instruction_txtbox, palm_if,
176
- global_context, res_temp, res_topk
177
  )
178
 
179
  ppm = res[idx]
@@ -338,15 +346,8 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
338
  with gr.Row():
339
  res_temp = gr.Slider(0.0, 2.0, 1.0, step=0.1, label="temp", interactive=True)
340
  res_topk = gr.Slider(20, 1000, 50, step=1, label="top_k", interactive=True)
341
- res_rpen = gr.Slider(0.0, 2.0, 1.2, step=0.1, label="rep_penalty", interactive=True)
342
- res_mnts = gr.Slider(64, 8192, 512, step=1, label="new_tokens", interactive=True)
343
- res_sample = gr.Radio([True, False], value=True, label="sample", interactive=True)
344
 
345
- with gr.Column():
346
- gr.Markdown("#### Context managements")
347
- with gr.Row():
348
- ctx_num_lconv = gr.Slider(2, 10, 3, step=1, label="number of recent talks to keep", interactive=True)
349
-
350
  gr.Markdown(
351
  "***NOTE:*** If you are subscribing [PRO](https://huggingface.co/pricing#pro), you can simply duplicate this space and use your "
352
  "Hugging Face Access Token to run the same application. Just add `HF_TOKEN` secret with the Token value accorindg to [this guide]"
@@ -370,7 +371,7 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
370
  ).then(
371
  chat_stream,
372
  [idx, local_data, instruction_txtbox, chat_state,
373
- global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
374
  internet_option, serper_api_key, palm_if],
375
  [instruction_txtbox, context_inspector, chatbot, local_data, regenerate, internet_option]
376
  ).then(
@@ -402,7 +403,7 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
402
  regen_event = regenerate.click(
403
  rollback_last,
404
  [idx, local_data, chat_state,
405
- global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
406
  internet_option, serper_api_key, palm_if],
407
  [context_inspector, chatbot, local_data, regenerate, internet_option]
408
  ).then(
 
152
 
153
  async def chat_stream(
154
  idx, local_data, instruction_txtbox, chat_state,
155
+ global_context, res_temp, res_topk, res_topp,
156
  internet_option, serper_api_key, palm_if
157
  ):
158
  internet_option = True if internet_option == "on" else False
 
171
  # search_prompt = tmp_prompt
172
  # yield "", prompt, uis, str(res), gr.update(interactive=False), "off"
173
 
174
+ parameters = {
175
+ 'model': 'models/text-bison-001',
176
+ 'candidate_count': 1,
177
+ 'temperature': res_temp,
178
+ 'top_k': res_topk,
179
+ 'top_p': res_topp,
180
+ }
181
+
182
  palm_if, response_txt = gen_text(
183
  instruction_txtbox, palm_if,
184
+ parameters=parameters
185
  )
186
 
187
  ppm = res[idx]
 
346
  with gr.Row():
347
  res_temp = gr.Slider(0.0, 2.0, 1.0, step=0.1, label="temp", interactive=True)
348
  res_topk = gr.Slider(20, 1000, 50, step=1, label="top_k", interactive=True)
349
+ res_topp = gr.Slider(0.0, 1.0, 0.9, step=0.1, label="top_p", interactive=True)
 
 
350
 
 
 
 
 
 
351
  gr.Markdown(
352
  "***NOTE:*** If you are subscribing [PRO](https://huggingface.co/pricing#pro), you can simply duplicate this space and use your "
353
  "Hugging Face Access Token to run the same application. Just add `HF_TOKEN` secret with the Token value accorindg to [this guide]"
 
371
  ).then(
372
  chat_stream,
373
  [idx, local_data, instruction_txtbox, chat_state,
374
+ global_context, res_temp, res_topk, res_topp,
375
  internet_option, serper_api_key, palm_if],
376
  [instruction_txtbox, context_inspector, chatbot, local_data, regenerate, internet_option]
377
  ).then(
 
403
  regen_event = regenerate.click(
404
  rollback_last,
405
  [idx, local_data, chat_state,
406
+ global_context, res_temp, res_topk, res_topp
407
  internet_option, serper_api_key, palm_if],
408
  [context_inspector, chatbot, local_data, regenerate, internet_option]
409
  ).then(