Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a compatible T5-based model for query parsing | |
| query_parser = pipeline("text2text-generation", model="google/flan-t5-small") | |
| def parse_query(user_query): | |
| """ | |
| Parse user e-commerce search query and return structured attributes. | |
| """ | |
| output = query_parser(user_query, max_length=50, do_sample=False) | |
| structured_response = output[0]['generated_text'] | |
| return structured_response | |
| # Define the Gradio UI | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🛍️ Luxury Fashion Query Parser") | |
| query_input = gr.Textbox(label="Enter your search query", placeholder="e.g., Gucci men’s perfume under 200AED") | |
| output_box = gr.Textbox(label="Structured Output", placeholder="Brand: Gucci, Gender: Men, Category: Perfume, Price: 0-200 AED") | |
| parse_button = gr.Button("Parse Query") | |
| parse_button.click(parse_query, inputs=[query_input], outputs=[output_box]) | |
| # Launch the app | |
| demo.launch() |