harpreetsahota commited on
Commit
c99bb54
·
verified ·
1 Parent(s): fd137e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -27
app.py CHANGED
@@ -98,6 +98,7 @@ def respond(
98
  yield f"Error: {str(e)}"
99
 
100
  with gr.Blocks() as demo:
 
101
  with gr.Row():
102
  with gr.Column():
103
  model_dropdown = gr.Dropdown(
@@ -111,6 +112,41 @@ with gr.Blocks() as demo:
111
  label="Select Prompt Strategy"
112
  )
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  chatbot = gr.ChatInterface(
115
  fn=respond,
116
  additional_inputs=[
@@ -126,37 +162,15 @@ with gr.Blocks() as demo:
126
  # Parameters and Prompt Details section below the chat
127
  with gr.Row():
128
  with gr.Column():
129
- # Parameter Controls
130
- override_params = gr.Checkbox(
131
- label="Override Template Parameters",
132
- value=False
133
- )
134
 
135
  with gr.Column(visible=False) as param_controls:
136
- max_tokens = gr.Slider(
137
- minimum=1,
138
- maximum=2048,
139
- value=512,
140
- step=1,
141
- label="Max new tokens"
142
- )
143
- temperature = gr.Slider(
144
- minimum=0.1,
145
- maximum=4.0,
146
- value=0.7,
147
- step=0.1,
148
- label="Temperature"
149
- )
150
- top_p = gr.Slider(
151
- minimum=0.1,
152
- maximum=1.0,
153
- value=0.95,
154
- step=0.05,
155
- label="Top-p (nucleus sampling)"
156
- )
157
 
158
  with gr.Column():
159
- # Prompt Details
160
  with gr.Accordion("Current Prompt Details", open=False):
161
  system_prompt_display = gr.TextArea(
162
  label="System Prompt",
 
98
  yield f"Error: {str(e)}"
99
 
100
  with gr.Blocks() as demo:
101
+ # First, define all input components we'll need
102
  with gr.Row():
103
  with gr.Column():
104
  model_dropdown = gr.Dropdown(
 
112
  label="Select Prompt Strategy"
113
  )
114
 
115
+ # Define parameter components before using them in ChatInterface
116
+ override_params = gr.Checkbox(
117
+ label="Override Template Parameters",
118
+ value=False,
119
+ visible=False # Initially hidden
120
+ )
121
+
122
+ max_tokens = gr.Slider(
123
+ minimum=1,
124
+ maximum=2048,
125
+ value=512,
126
+ step=1,
127
+ label="Max new tokens",
128
+ visible=False
129
+ )
130
+
131
+ temperature = gr.Slider(
132
+ minimum=0.1,
133
+ maximum=4.0,
134
+ value=0.7,
135
+ step=0.1,
136
+ label="Temperature",
137
+ visible=False
138
+ )
139
+
140
+ top_p = gr.Slider(
141
+ minimum=0.1,
142
+ maximum=1.0,
143
+ value=0.95,
144
+ step=0.05,
145
+ label="Top-p (nucleus sampling)",
146
+ visible=False
147
+ )
148
+
149
+ # Now we can use all components in ChatInterface
150
  chatbot = gr.ChatInterface(
151
  fn=respond,
152
  additional_inputs=[
 
162
  # Parameters and Prompt Details section below the chat
163
  with gr.Row():
164
  with gr.Column():
165
+ # Make override params visible here
166
+ override_params.visible = True
 
 
 
167
 
168
  with gr.Column(visible=False) as param_controls:
169
+ max_tokens.visible = True
170
+ temperature.visible = True
171
+ top_p.visible = True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  with gr.Column():
 
174
  with gr.Accordion("Current Prompt Details", open=False):
175
  system_prompt_display = gr.TextArea(
176
  label="System Prompt",