TobDeBer commited on
Commit
cab2b06
Β·
1 Parent(s): 0c489f4

GUI simplify

Browse files
Files changed (1) hide show
  1. app.py +69 -91
app.py CHANGED
@@ -101,7 +101,7 @@ def generate_text(
101
 
102
  def clear_chat():
103
  """Clear the chat interface"""
104
- return "", ""
105
 
106
  # Create custom theme
107
  custom_theme = gr.themes.Soft(
@@ -132,97 +132,75 @@ with gr.Blocks() as demo:
132
  """
133
  )
134
 
135
- with gr.Row():
136
- with gr.Column(scale=2):
137
- # Model loading section (Removed as per request)
138
- # The model is loaded automatically at startup.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- with gr.Group():
141
- # Generation parameters
142
- gr.Markdown("### βš™οΈ Generation Parameters")
143
-
144
- with gr.Row():
145
- max_length = gr.Slider(
146
- minimum=50,
147
- maximum=1024,
148
- value=200,
149
- step=50,
150
- label="Max Tokens"
151
- )
152
- temperature = gr.Slider(
153
- minimum=0.1,
154
- maximum=2.0,
155
- value=0.7,
156
- step=0.1,
157
- label="Temperature"
158
- )
159
-
160
- with gr.Row():
161
- top_p = gr.Slider(
162
- minimum=0.1,
163
- maximum=1.0,
164
- value=0.95,
165
- step=0.05,
166
- label="Top-p"
167
- )
168
- repetition_penalty = gr.Slider(
169
- minimum=1.0,
170
- maximum=2.0,
171
- value=1.1,
172
- step=0.1,
173
- label="Repetition Penalty"
174
- )
175
-
176
- system_prompt = gr.Textbox(
177
- label="System Prompt",
178
- value="You are a helpful AI assistant. Provide clear and concise answers.",
179
- lines=3,
180
- placeholder="Enter a system prompt to guide the model's behavior..."
181
- )
182
 
183
- with gr.Column(scale=3):
184
- # Main interface
185
- with gr.Group():
186
- gr.Markdown("### πŸ’¬ Text Generation")
187
-
188
- prompt_input = gr.Textbox(
189
- label="Enter your prompt",
190
- placeholder="Type your message here...",
191
- lines=4,
192
- autofocus=True
193
- )
194
-
195
- with gr.Row():
196
- generate_btn = gr.Button(
197
- "πŸš€ Generate",
198
- variant="primary",
199
- size="lg"
200
- )
201
- clear_btn = gr.Button(
202
- "πŸ—‘οΈ Clear",
203
- variant="secondary"
204
- )
205
-
206
- output_text = gr.Markdown(
207
- label="Generated Response",
208
- value="*Response will appear here...*"
209
- )
210
-
211
- # Example prompts
212
- with gr.Accordion("πŸ“ Example Prompts", open=False):
213
- gr.Examples(
214
- examples=[
215
- ["Write a short story about a robot discovering music."],
216
- ["Explain quantum computing in simple terms."],
217
- ["Create a poem about the changing seasons."],
218
- ["What are the benefits of renewable energy?"],
219
- ["Write a Python function to calculate fibonacci numbers."],
220
- ["Describe the perfect day in your own words."],
221
- ["Explain the concept of machine learning to a beginner."],
222
- ["Create a dialogue between two friends planning a trip."]
223
- ],
224
- inputs=[prompt_input],
225
- label="Click an example to get started"
226
  )
227
 
228
  # Event handlers
@@ -244,7 +222,7 @@ with gr.Blocks() as demo:
244
 
245
  clear_btn.click(
246
  fn=clear_chat,
247
- outputs=[prompt_input],
248
  api_visibility="private"
249
  )
250
 
 
101
 
102
  def clear_chat():
103
  """Clear the chat interface"""
104
+ return "", "*Response will appear here...*"
105
 
106
  # Create custom theme
107
  custom_theme = gr.themes.Soft(
 
132
  """
133
  )
134
 
135
+ # Main interface
136
+ with gr.Group():
137
+ gr.Markdown("### πŸ’¬ Text Generation")
138
+
139
+ prompt_input = gr.Textbox(
140
+ label="Enter your prompt",
141
+ placeholder="Type your message here...",
142
+ lines=4,
143
+ autofocus=True
144
+ )
145
+
146
+ with gr.Row():
147
+ generate_btn = gr.Button(
148
+ "πŸš€ Generate",
149
+ variant="primary",
150
+ size="lg"
151
+ )
152
+ clear_btn = gr.Button(
153
+ "πŸ—‘οΈ Clear",
154
+ variant="secondary"
155
+ )
156
+
157
+ output_text = gr.Markdown(
158
+ label="Generated Response",
159
+ value="*Response will appear here...*"
160
+ )
161
 
162
+ # Settings
163
+ with gr.Accordion("βš™οΈ Settings", open=False):
164
+ # Generation parameters
165
+ gr.Markdown("### βš™οΈ Generation Parameters")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
+ with gr.Row():
168
+ max_length = gr.Slider(
169
+ minimum=50,
170
+ maximum=1024,
171
+ value=200,
172
+ step=50,
173
+ label="Max Tokens"
174
+ )
175
+ temperature = gr.Slider(
176
+ minimum=0.1,
177
+ maximum=2.0,
178
+ value=0.7,
179
+ step=0.1,
180
+ label="Temperature"
181
+ )
182
+
183
+ with gr.Row():
184
+ top_p = gr.Slider(
185
+ minimum=0.1,
186
+ maximum=1.0,
187
+ value=0.95,
188
+ step=0.05,
189
+ label="Top-p"
190
+ )
191
+ repetition_penalty = gr.Slider(
192
+ minimum=1.0,
193
+ maximum=2.0,
194
+ value=1.1,
195
+ step=0.1,
196
+ label="Repetition Penalty"
197
+ )
198
+
199
+ system_prompt = gr.Textbox(
200
+ label="System Prompt",
201
+ value="You are a helpful AI assistant. Provide clear and concise answers.",
202
+ lines=3,
203
+ placeholder="Enter a system prompt to guide the model's behavior..."
 
 
 
 
 
 
204
  )
205
 
206
  # Event handlers
 
222
 
223
  clear_btn.click(
224
  fn=clear_chat,
225
+ outputs=[prompt_input, output_text],
226
  api_visibility="private"
227
  )
228