chansung commited on
Commit
de4d793
1 Parent(s): c1d72c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -87,6 +87,29 @@ def set_chatbot(btn, ld, state):
87
  def set_example(btn):
88
  return btn, gr.update(visible=False)
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
91
  with gr.Column() as chat_view:
92
  idx = gr.State(0)
 
87
  def set_example(btn):
88
  return btn, gr.update(visible=False)
89
 
90
+ def get_final_template(
91
+ txt, placeholder_txt1, placeholder_txt2, placeholder_txt3
92
+ ):
93
+ placeholders = get_placeholders(txt)
94
+ example_prompt = txt
95
+
96
+ if len(placeholders) >= 1:
97
+ if placeholder_txt1 != "":
98
+ example_prompt = example_prompt.replace(f"[{placeholders[0]}]", placeholder_txt1)
99
+ if len(placeholders) >= 2:
100
+ if placeholder_txt2 != "":
101
+ example_prompt = example_prompt.replace(f"[{placeholders[1]}]", placeholder_txt2)
102
+ if len(placeholders) >= 3:
103
+ if placeholder_txt3 != "":
104
+ example_prompt = example_prompt.replace(f"[{placeholders[2]}]", placeholder_txt3)
105
+
106
+ return (
107
+ example_prompt,
108
+ "",
109
+ "",
110
+ ""
111
+ )
112
+
113
  with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
114
  with gr.Column() as chat_view:
115
  idx = gr.State(0)