Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# Load Hugging Face model (zero-shot query parsing) | |
query_parser = pipeline("text2text-generation", model="EmbeddingStudio/query-parser-saiga-mistral-7b-lora") | |
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 UI with Gradio | |
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() |