Spaces:
Sleeping
Sleeping
GUI simplify
Browse files
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 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 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.
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 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 |
|