Spaces:
Running
Running
File size: 2,119 Bytes
7aaee26 76c6f72 7aaee26 87b7e29 76c6f72 7276ec0 8367d9c 76c6f72 18d7d72 87b7e29 f4d6cf1 18d7d72 76c6f72 87b7e29 18d7d72 7aaee26 87b7e29 7aaee26 7276ec0 7aaee26 7276ec0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import gradio as gr
from smart_suggestion.flan_suggestor import generate_product_description
def create_suggestions_tab():
with gr.TabItem("π Smart Suggestions"):
# π· Header
gr.Markdown(
"""
## π€ Ask RetailGenie for Recommendations
π§ Just type your need β e.g., _"shampoo for dry hair under 500"_, _"gift sets"_, or _"budget skin care"_
and let Genie do the rest!
""",
elem_classes="centered-text"
)
# π© Input Section
suggestion_input = gr.Textbox(
label="π¬ Your Request",
placeholder="Try: Gifts under 500, or Shampoo for dry hair",
lines=1
)
gr.Markdown("<div style='margin-top: 8px;'></div>")
# π¦ Button
suggest_btn = gr.Button("π Get Suggestions")
gr.Markdown("<div style='margin-top: 12px;'></div>")
# π¨ Output Section
suggestions_output = gr.Textbox(
label="β¨ Suggested Products",
lines=10,
interactive=False,
show_copy_button=True,
elem_id="suggestion-box"
)
# π§ Connect logic to FLAN model
suggest_btn.click(
fn=generate_product_description,
inputs=suggestion_input,
outputs=suggestions_output
)
# π
CSS for centered text and consistent spacing
gr.Markdown(
"""
<style>
.centered-text {
text-align: center;
font-size: 16px;
font-weight: 500;
}
#suggestion-box textarea {
font-family: 'Courier New', monospace;
font-size: 14px;
background-color: #111827;
color: #e5e7eb;
border-radius: 10px;
padding: 10px;
white-space: pre-line; /* important for preserving line breaks */
}
</style>
"""
)
|