Spaces:
Sleeping
Sleeping
compare to chicory-ui
Browse files
ui.py
CHANGED
@@ -121,9 +121,34 @@ def create_demo():
|
|
121 |
hr {
|
122 |
border-color: #333 !important;
|
123 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
""") as demo:
|
125 |
gr.Markdown("# Product Categorization Tool\nAnalyze products and find the most similar ingredients using AI embeddings.")
|
126 |
-
gr.Markdown("Use **Enter** to quickly categorize products (shortcut works in both tabs).")
|
127 |
|
128 |
with gr.Tabs() as tabs:
|
129 |
with gr.TabItem("Text Input"):
|
@@ -177,12 +202,12 @@ def create_demo():
|
|
177 |
outputs=text_input
|
178 |
)
|
179 |
|
180 |
-
#
|
181 |
-
text_input.submit(
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
)
|
186 |
|
187 |
process_btn.click(
|
188 |
fn=categorize_products,
|
|
|
121 |
hr {
|
122 |
border-color: #333 !important;
|
123 |
}
|
124 |
+
""", js="""
|
125 |
+
document.addEventListener('keydown', function(e) {
|
126 |
+
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
127 |
+
// Find the active tab
|
128 |
+
const tabs = document.querySelector('.tabs');
|
129 |
+
if (!tabs) return;
|
130 |
+
|
131 |
+
const activeTabIndex = Array.from(tabs.querySelectorAll('button'))
|
132 |
+
.findIndex(tab => tab.getAttribute('aria-selected') === 'true');
|
133 |
+
|
134 |
+
// Find the submit button in the active tab content
|
135 |
+
const tabContents = document.querySelectorAll('.tabitem');
|
136 |
+
if (activeTabIndex < 0 || activeTabIndex >= tabContents.length) return;
|
137 |
+
|
138 |
+
const activeTab = tabContents[activeTabIndex];
|
139 |
+
const button = activeTabIndex === 0
|
140 |
+
? activeTab.querySelector('button[variant="primary"]') // Text Input tab
|
141 |
+
: activeTab.querySelector('button[variant="primary"]'); // File Upload tab
|
142 |
+
|
143 |
+
if (button) {
|
144 |
+
button.click();
|
145 |
+
e.preventDefault();
|
146 |
+
}
|
147 |
+
}
|
148 |
+
});
|
149 |
""") as demo:
|
150 |
gr.Markdown("# Product Categorization Tool\nAnalyze products and find the most similar ingredients using AI embeddings.")
|
151 |
+
gr.Markdown("Use **Cmd+Enter** (or Ctrl+Enter) to quickly categorize products (shortcut works in both tabs).")
|
152 |
|
153 |
with gr.Tabs() as tabs:
|
154 |
with gr.TabItem("Text Input"):
|
|
|
202 |
outputs=text_input
|
203 |
)
|
204 |
|
205 |
+
# Remove the Enter key trigger as we're now using Cmd+Enter/Ctrl+Enter instead
|
206 |
+
# text_input.submit(
|
207 |
+
# fn=categorize_products,
|
208 |
+
# inputs=[text_input, gr.State(False), top_n, confidence],
|
209 |
+
# outputs=text_output
|
210 |
+
# )
|
211 |
|
212 |
process_btn.click(
|
213 |
fn=categorize_products,
|