harpreetsahota commited on
Commit
5283206
·
verified ·
1 Parent(s): 9a56c61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -139,6 +139,16 @@ with gr.Blocks() as demo:
139
  label="Top-p (nucleus sampling)"
140
  )
141
 
 
 
 
 
 
 
 
 
 
 
142
  chatbot = gr.ChatInterface(
143
  fn=respond,
144
  additional_inputs=[
@@ -154,6 +164,29 @@ with gr.Blocks() as demo:
154
  def toggle_param_controls(override):
155
  return gr.Column(visible=override)
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  override_params.change(
158
  toggle_param_controls,
159
  inputs=[override_params],
 
139
  label="Top-p (nucleus sampling)"
140
  )
141
 
142
+ with gr.Accordion("Current Prompt Details", open=False):
143
+ system_prompt_display = gr.TextArea(
144
+ label="System Prompt",
145
+ interactive=False,
146
+ lines=3
147
+ )
148
+ current_messages_display = gr.JSON(
149
+ label="Full Conversation Context",
150
+ )
151
+
152
  chatbot = gr.ChatInterface(
153
  fn=respond,
154
  additional_inputs=[
 
164
  def toggle_param_controls(override):
165
  return gr.Column(visible=override)
166
 
167
+ def update_prompt_display(prompt_strategy):
168
+ prompt_template = prompts[PROMPT_STRATEGIES[prompt_strategy]]
169
+ system_context = prompts["system_context"]
170
+ formatted_system_message = system_context.format(prompt_strategy=prompt_template.template)
171
+
172
+ # Get the template parameters
173
+ params = prompt_template.parameters
174
+
175
+ return (
176
+ formatted_system_message,
177
+ {
178
+ "Template Parameters": params,
179
+ "Prompt Strategy": prompt_template.template
180
+ }
181
+ )
182
+
183
+ # Update prompt display when strategy changes
184
+ prompt_strategy_dropdown.change(
185
+ update_prompt_display,
186
+ inputs=[prompt_strategy_dropdown],
187
+ outputs=[system_prompt_display, current_messages_display]
188
+ )
189
+
190
  override_params.change(
191
  toggle_param_controls,
192
  inputs=[override_params],