Update app.py
Browse files
app.py
CHANGED
@@ -221,10 +221,52 @@ def gradio_interface():
|
|
221 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
|
222 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, step=0.1, label="Top P")
|
223 |
max_tokens = gr.Number(label="Max Tokens", value=300)
|
|
|
224 |
stop = gr.Textbox(label="Stop Sequences (comma-separated)")
|
225 |
random_seed = gr.Number(label="Random Seed", value=None)
|
226 |
safe_prompt = gr.Checkbox(label="Safe Prompt", value=False)
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
submit_btn = gr.Button(
|
229 |
"π Run Analysis",
|
230 |
variant="primary",
|
@@ -358,6 +400,24 @@ def gradio_interface():
|
|
358 |
background-color: #F3F4F6 !important;
|
359 |
padding: 12px !important;
|
360 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
</style>
|
362 |
""")
|
363 |
|
|
|
221 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature")
|
222 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, step=0.1, label="Top P")
|
223 |
max_tokens = gr.Number(label="Max Tokens", value=300)
|
224 |
+
min_tokens = gr.Number(label="Min Tokens", value=None)
|
225 |
stop = gr.Textbox(label="Stop Sequences (comma-separated)")
|
226 |
random_seed = gr.Number(label="Random Seed", value=None)
|
227 |
safe_prompt = gr.Checkbox(label="Safe Prompt", value=False)
|
228 |
|
229 |
+
# Add Examples Section with enhanced styling
|
230 |
+
gr.HTML("""
|
231 |
+
<div style="padding: 15px; background-color: #F3F4F6; border-radius: 8px; margin: 20px 0;">
|
232 |
+
<h3 style="color: #4F46E5; margin-bottom: 10px;">π Example Prompts</h3>
|
233 |
+
<p style="color: #6B7280; font-size: 0.9rem;">Try these pre-configured examples to get started</p>
|
234 |
+
</div>
|
235 |
+
""")
|
236 |
+
|
237 |
+
examples = [
|
238 |
+
# Example 1: Sentiment Analysis
|
239 |
+
["Sentiment Analysis",
|
240 |
+
"You are an AI trained to analyze the sentiment of text. Provide a detailed analysis of the emotional tone, highlighting key phrases that indicate sentiment.",
|
241 |
+
"The new restaurant downtown exceeded all my expectations. The food was exquisite, the service impeccable, and the ambiance was perfect for a romantic evening. I can't wait to go back!",
|
242 |
+
0.3, 0.95, 200, None, "", None, False],
|
243 |
+
|
244 |
+
# Example 2: Creative Writing
|
245 |
+
["Story Generation",
|
246 |
+
"You are a creative writer. Generate a short, engaging story based on the given prompt. Include vivid descriptions and an unexpected twist.",
|
247 |
+
"In a world where dreams are shared, a young girl discovers she can manipulate other people's dreams.",
|
248 |
+
0.9, 0.8, 500, 300, "The end", None, False]
|
249 |
+
]
|
250 |
+
|
251 |
+
gr.Examples(
|
252 |
+
examples=examples,
|
253 |
+
inputs=[
|
254 |
+
task, system_prompt, input_text,
|
255 |
+
temperature, top_p, max_tokens,
|
256 |
+
min_tokens, stop, random_seed,
|
257 |
+
safe_prompt
|
258 |
+
],
|
259 |
+
outputs=[
|
260 |
+
omn_response, ml_response,
|
261 |
+
large_sentiment, open_sentiment,
|
262 |
+
large_keywords, open_keywords,
|
263 |
+
large_readability, open_readability
|
264 |
+
],
|
265 |
+
fn=run_inference_and_analysis,
|
266 |
+
cache_examples=True,
|
267 |
+
elem_classes="examples-style"
|
268 |
+
)
|
269 |
+
|
270 |
submit_btn = gr.Button(
|
271 |
"π Run Analysis",
|
272 |
variant="primary",
|
|
|
400 |
background-color: #F3F4F6 !important;
|
401 |
padding: 12px !important;
|
402 |
}
|
403 |
+
.examples-style {
|
404 |
+
margin: 20px 0;
|
405 |
+
padding: 15px;
|
406 |
+
border: 1px solid #E5E7EB;
|
407 |
+
border-radius: 8px;
|
408 |
+
background-color: white;
|
409 |
+
}
|
410 |
+
.examples-style .example-card {
|
411 |
+
border: 1px solid #E5E7EB;
|
412 |
+
border-radius: 6px;
|
413 |
+
padding: 12px;
|
414 |
+
margin-bottom: 10px;
|
415 |
+
transition: all 0.2s;
|
416 |
+
}
|
417 |
+
.examples-style .example-card:hover {
|
418 |
+
border-color: #4F46E5;
|
419 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
420 |
+
}
|
421 |
</style>
|
422 |
""")
|
423 |
|