ryanrwatkins commited on
Commit
b982841
1 Parent(s): 390942c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -45,6 +45,7 @@ def get_empty_state():
45
 
46
  #Initial prompt template, others added below from TXT file
47
  prompt_templates = {"All Needs Experts": "Respond as if you are combiation of all needs assessment experts."}
 
48
 
49
  def download_prompt_templates():
50
  url = "https://huggingface.co/spaces/ryanrwatkins/needs/raw/main/gurus.txt"
@@ -58,6 +59,7 @@ def download_prompt_templates():
58
  prompt = row[1].strip('"')
59
  description = row[2].strip('"')
60
  prompt_templates[act] = prompt
 
61
 
62
 
63
 
@@ -67,11 +69,11 @@ def download_prompt_templates():
67
 
68
  choices = list(prompt_templates.keys())
69
  choices = choices[:1] + sorted(choices[1:])
70
- return gr.update(value=choices[0], choices=choices, description=description)
71
 
72
  def on_prompt_template_change(prompt_template):
73
  if not isinstance(prompt_template, str): return
74
- return prompt_templates[prompt_template]
75
 
76
 
77
 
@@ -240,7 +242,7 @@ with gr.Blocks(css=css) as demo:
240
  btn_clear_conversation = gr.Button("Start New Conversation")
241
  with gr.Column():
242
  prompt_template = gr.Dropdown(label="Choose a expert:", choices=list(prompt_templates.keys()))
243
- prompt_template_preview = gr.Markdown(elem_id="prompt_template_preview", label=description)
244
  with gr.Accordion("Advanced parameters", open=False):
245
  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")
246
  max_tokens = gr.Slider(minimum=100, maximum=400, value=200, step=1, label="Max tokens per response")
@@ -250,7 +252,7 @@ with gr.Blocks(css=css) as demo:
250
  btn_submit.click(submit_message, [ input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
251
  input_message.submit(submit_message, [ input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
252
  btn_clear_conversation.click(clear_conversation, [], [input_message, chatbot, total_tokens_str, state])
253
- prompt_template.change(on_prompt_template_change, inputs=[prompt_template], outputs=[prompt_template_preview])
254
 
255
 
256
 
 
45
 
46
  #Initial prompt template, others added below from TXT file
47
  prompt_templates = {"All Needs Experts": "Respond as if you are combiation of all needs assessment experts."}
48
+ actor_description = {}
49
 
50
  def download_prompt_templates():
51
  url = "https://huggingface.co/spaces/ryanrwatkins/needs/raw/main/gurus.txt"
 
59
  prompt = row[1].strip('"')
60
  description = row[2].strip('"')
61
  prompt_templates[act] = prompt
62
+ actor_description[act] = description
63
 
64
 
65
 
 
69
 
70
  choices = list(prompt_templates.keys())
71
  choices = choices[:1] + sorted(choices[1:])
72
+ return gr.update(value=choices[0], choices=choices)
73
 
74
  def on_prompt_template_change(prompt_template):
75
  if not isinstance(prompt_template, str): return
76
+ return prompt_templates[prompt_template], actor_description[prompt_template]
77
 
78
 
79
 
 
242
  btn_clear_conversation = gr.Button("Start New Conversation")
243
  with gr.Column():
244
  prompt_template = gr.Dropdown(label="Choose a expert:", choices=list(prompt_templates.keys()))
245
+ prompt_template_preview = gr.Markdown(elem_id="prompt_template_preview")
246
  with gr.Accordion("Advanced parameters", open=False):
247
  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")
248
  max_tokens = gr.Slider(minimum=100, maximum=400, value=200, step=1, label="Max tokens per response")
 
252
  btn_submit.click(submit_message, [ input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
253
  input_message.submit(submit_message, [ input_message, prompt_template, temperature, max_tokens, context_length, state], [input_message, chatbot, total_tokens_str, state])
254
  btn_clear_conversation.click(clear_conversation, [], [input_message, chatbot, total_tokens_str, state])
255
+ prompt_template.change(on_prompt_template_change, inputs=[actor_description], outputs=[prompt_template_preview])
256
 
257
 
258