File size: 983 Bytes
75fdda9
 
 
3f017a8
 
75fdda9
 
 
 
 
 
 
 
 
3f017a8
75fdda9
 
 
 
 
 
 
 
 
 
 
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
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()