DINGOLANI commited on
Commit
75fdda9
·
verified ·
1 Parent(s): e6974be

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load Hugging Face model (zero-shot query parsing)
5
+ query_parser = pipeline("text2text-generation", model="EmbeddingStudio/query-parser-saiga-mistral-7b-lora")
6
+
7
+ def parse_query(user_query):
8
+ """
9
+ Parse user e-commerce search query and return structured attributes.
10
+ """
11
+ output = query_parser(user_query, max_length=50, do_sample=False)
12
+ structured_response = output[0]['generated_text']
13
+
14
+ return structured_response
15
+
16
+ # Define UI with Gradio
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("# 🛍️ Luxury Fashion Query Parser")
19
+
20
+ query_input = gr.Textbox(label="Enter your search query", placeholder="e.g., Gucci men’s perfume under 200AED")
21
+
22
+ output_box = gr.Textbox(label="Structured Output", placeholder="Brand: Gucci, Gender: Men, Category: Perfume, Price: 0-200 AED")
23
+
24
+ parse_button = gr.Button("Parse Query")
25
+
26
+ parse_button.click(parse_query, inputs=[query_input], outputs=[output_box])
27
+
28
+ # Launch the app
29
+ demo.launch()