Spaces:
Sleeping
Sleeping
compare to chicory-ui
Browse files
ui.py
CHANGED
@@ -7,6 +7,24 @@ from chicory_api import call_chicory_parser
|
|
7 |
# Global variable for embeddings
|
8 |
embeddings = {}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def categorize_products(product_input, is_file=False, top_n=5, confidence_threshold=0.5, progress=None):
|
11 |
"""Categorize products from text input or file"""
|
12 |
progress_tracker = SafeProgress(progress)
|
@@ -61,6 +79,10 @@ def categorize_products(product_input, is_file=False, top_n=5, confidence_thresh
|
|
61 |
progress_tracker(1.0, desc="Done!")
|
62 |
return output_html
|
63 |
|
|
|
|
|
|
|
|
|
64 |
def create_demo():
|
65 |
"""Create the Gradio interface"""
|
66 |
with gr.Blocks(css="""
|
@@ -117,7 +139,10 @@ def create_demo():
|
|
117 |
with input_controls:
|
118 |
top_n = gr.Slider(1, 25, 5, label="Top N Results")
|
119 |
confidence = gr.Slider(0.1, 0.9, 0.5, label="Confidence Threshold")
|
120 |
-
|
|
|
|
|
|
|
121 |
|
122 |
with gr.Column(scale=1):
|
123 |
# Results section
|
@@ -145,6 +170,13 @@ def create_demo():
|
|
145 |
outputs=text_output
|
146 |
)
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
process_btn.click(
|
149 |
fn=categorize_products,
|
150 |
inputs=[file_input, gr.State(True), file_top_n, file_confidence],
|
|
|
7 |
# Global variable for embeddings
|
8 |
embeddings = {}
|
9 |
|
10 |
+
# Sample product names for the example button
|
11 |
+
EXAMPLE_PRODUCTS = """Nature's Promise Spring Water Multipack
|
12 |
+
Red's Burritos
|
13 |
+
Nature's Promise Spring Water Multipack
|
14 |
+
Schweppes Seltzer 12 Pack
|
15 |
+
Hunt's Pasta Sauce
|
16 |
+
Buitoni Filled Pasta
|
17 |
+
Buitoni Filled Pasta
|
18 |
+
Samuel Adams or Blue Moon 12 Pack
|
19 |
+
Mrs. T's Pierogies
|
20 |
+
Buitoni Filled Pasta
|
21 |
+
Pillsbury Dough
|
22 |
+
Nature's Promise Organic Celery Hearts
|
23 |
+
MorningStar Farms Meatless Nuggets, Patties or Crumbles
|
24 |
+
Nature's Promise Organic Celery Hearts
|
25 |
+
Boar's Head Mild Provolone Cheese
|
26 |
+
Athenos Feta Crumbles"""
|
27 |
+
|
28 |
def categorize_products(product_input, is_file=False, top_n=5, confidence_threshold=0.5, progress=None):
|
29 |
"""Categorize products from text input or file"""
|
30 |
progress_tracker = SafeProgress(progress)
|
|
|
79 |
progress_tracker(1.0, desc="Done!")
|
80 |
return output_html
|
81 |
|
82 |
+
def load_examples():
|
83 |
+
"""Load example product names into the text input"""
|
84 |
+
return EXAMPLE_PRODUCTS
|
85 |
+
|
86 |
def create_demo():
|
87 |
"""Create the Gradio interface"""
|
88 |
with gr.Blocks(css="""
|
|
|
139 |
with input_controls:
|
140 |
top_n = gr.Slider(1, 25, 5, label="Top N Results")
|
141 |
confidence = gr.Slider(0.1, 0.9, 0.5, label="Confidence Threshold")
|
142 |
+
|
143 |
+
with gr.Row():
|
144 |
+
examples_btn = gr.Button("Load Examples", variant="secondary")
|
145 |
+
categorize_btn = gr.Button("Categorize", variant="primary")
|
146 |
|
147 |
with gr.Column(scale=1):
|
148 |
# Results section
|
|
|
170 |
outputs=text_output
|
171 |
)
|
172 |
|
173 |
+
# Add examples button functionality
|
174 |
+
examples_btn.click(
|
175 |
+
fn=load_examples,
|
176 |
+
inputs=[],
|
177 |
+
outputs=text_input
|
178 |
+
)
|
179 |
+
|
180 |
process_btn.click(
|
181 |
fn=categorize_products,
|
182 |
inputs=[file_input, gr.State(True), file_top_n, file_confidence],
|