Spaces:
Running
on
L4
Running
on
L4
Upload folder using huggingface_hub
Browse files- frontend/app.py +12 -4
- globals.css +0 -14
- main.py +9 -4
- output.css +53 -15
frontend/app.py
CHANGED
|
@@ -197,9 +197,9 @@ def Search(request, search_results=[]):
|
|
| 197 |
|
| 198 |
def LoadingMessage():
|
| 199 |
return Div(
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
cls="p-10 text-center
|
| 203 |
id="loading-indicator",
|
| 204 |
)
|
| 205 |
|
|
@@ -248,13 +248,21 @@ def SearchResult(results: list, query_id: Optional[str] = None):
|
|
| 248 |
data_image_src=full_image_base64,
|
| 249 |
cls="reset-button pointer-events-auto font-mono text-xs h-5 rounded-none px-2",
|
| 250 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
# Add "Tokens" button - this has no action, just a placeholder
|
| 252 |
tokens_button = Button(
|
| 253 |
-
|
| 254 |
"Tokens",
|
| 255 |
size="sm",
|
| 256 |
cls="tokens-button flex gap-[3px] font-bold pointer-events-none font-mono text-xs h-5 rounded-none px-2",
|
| 257 |
)
|
|
|
|
| 258 |
result_items.append(
|
| 259 |
Div(
|
| 260 |
Div(
|
|
|
|
| 197 |
|
| 198 |
def LoadingMessage():
|
| 199 |
return Div(
|
| 200 |
+
Lucide(icon="loader-circle", cls="size-5 mr-1.5 animate-spin"),
|
| 201 |
+
Span("Retrieving search results", cls="text-base text-center"),
|
| 202 |
+
cls="p-10 text-muted-foreground flex items-center justify-center",
|
| 203 |
id="loading-indicator",
|
| 204 |
)
|
| 205 |
|
|
|
|
| 248 |
data_image_src=full_image_base64,
|
| 249 |
cls="reset-button pointer-events-auto font-mono text-xs h-5 rounded-none px-2",
|
| 250 |
)
|
| 251 |
+
|
| 252 |
+
tokens_icon = (
|
| 253 |
+
Lucide(icon="loader-circle", size="15", cls="animate-spin")
|
| 254 |
+
if query_id is not None
|
| 255 |
+
else Lucide(icon="images", size="15")
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
# Add "Tokens" button - this has no action, just a placeholder
|
| 259 |
tokens_button = Button(
|
| 260 |
+
tokens_icon,
|
| 261 |
"Tokens",
|
| 262 |
size="sm",
|
| 263 |
cls="tokens-button flex gap-[3px] font-bold pointer-events-none font-mono text-xs h-5 rounded-none px-2",
|
| 264 |
)
|
| 265 |
+
|
| 266 |
result_items.append(
|
| 267 |
Div(
|
| 268 |
Div(
|
globals.css
CHANGED
|
@@ -148,15 +148,6 @@
|
|
| 148 |
}
|
| 149 |
}
|
| 150 |
|
| 151 |
-
@keyframes rotate {
|
| 152 |
-
from {
|
| 153 |
-
transform: rotate(0deg);
|
| 154 |
-
}
|
| 155 |
-
to {
|
| 156 |
-
transform: rotate(360deg);
|
| 157 |
-
}
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
.animate-fade-in {
|
| 161 |
animation: fade-in 1s ease-out forwards;
|
| 162 |
}
|
|
@@ -165,11 +156,6 @@
|
|
| 165 |
animation: slide-up 1s ease-out forwards;
|
| 166 |
}
|
| 167 |
|
| 168 |
-
.animate-rotate {
|
| 169 |
-
animation: rotate 2s linear infinite;
|
| 170 |
-
display: inline;
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
.sim-map-button.active {
|
| 174 |
background-color: #61D790;
|
| 175 |
color: #2E2F27;
|
|
|
|
| 148 |
}
|
| 149 |
}
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
.animate-fade-in {
|
| 152 |
animation: fade-in 1s ease-out forwards;
|
| 153 |
}
|
|
|
|
| 156 |
animation: slide-up 1s ease-out forwards;
|
| 157 |
}
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
.sim-map-button.active {
|
| 160 |
background-color: #61D790;
|
| 161 |
color: #2E2F27;
|
main.py
CHANGED
|
@@ -27,6 +27,7 @@ highlight_js = HighlightJS(
|
|
| 27 |
light="github",
|
| 28 |
)
|
| 29 |
|
|
|
|
| 30 |
app, rt = fast_app(
|
| 31 |
htmlkw={"cls": "h-full"},
|
| 32 |
pico=False,
|
|
@@ -46,6 +47,12 @@ task_cache = LRUCache(
|
|
| 46 |
thread_pool = ThreadPoolExecutor()
|
| 47 |
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
def generate_query_id(query):
|
| 50 |
return hashlib.md5(query.encode("utf-8")).hexdigest()
|
| 51 |
|
|
@@ -111,10 +118,8 @@ async def get(request, query: str, nn: bool = True):
|
|
| 111 |
# If task is not completed, return the results with query_id
|
| 112 |
return SearchResult(search_results, query_id)
|
| 113 |
task_cache.set(query_id, False)
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
model = manager.model
|
| 117 |
-
processor = manager.processor
|
| 118 |
q_embs, token_to_idx = get_query_embeddings_and_token_map(processor, model, query)
|
| 119 |
|
| 120 |
start = time.perf_counter()
|
|
|
|
| 27 |
light="github",
|
| 28 |
)
|
| 29 |
|
| 30 |
+
|
| 31 |
app, rt = fast_app(
|
| 32 |
htmlkw={"cls": "h-full"},
|
| 33 |
pico=False,
|
|
|
|
| 47 |
thread_pool = ThreadPoolExecutor()
|
| 48 |
|
| 49 |
|
| 50 |
+
@app.on_event("startup")
|
| 51 |
+
def load_model_on_startup():
|
| 52 |
+
app.manager = ModelManager.get_instance()
|
| 53 |
+
return
|
| 54 |
+
|
| 55 |
+
|
| 56 |
def generate_query_id(query):
|
| 57 |
return hashlib.md5(query.encode("utf-8")).hexdigest()
|
| 58 |
|
|
|
|
| 118 |
# If task is not completed, return the results with query_id
|
| 119 |
return SearchResult(search_results, query_id)
|
| 120 |
task_cache.set(query_id, False)
|
| 121 |
+
model = app.manager.model
|
| 122 |
+
processor = app.manager.processor
|
|
|
|
|
|
|
| 123 |
q_embs, token_to_idx = get_query_embeddings_and_token_map(processor, model, query)
|
| 124 |
|
| 125 |
start = time.perf_counter()
|
output.css
CHANGED
|
@@ -801,6 +801,10 @@ body {
|
|
| 801 |
margin-bottom: 0.25rem;
|
| 802 |
}
|
| 803 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 804 |
.mt-2 {
|
| 805 |
margin-top: 0.5rem;
|
| 806 |
}
|
|
@@ -842,6 +846,11 @@ body {
|
|
| 842 |
height: 1rem;
|
| 843 |
}
|
| 844 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 845 |
.h-10 {
|
| 846 |
height: 2.5rem;
|
| 847 |
}
|
|
@@ -930,6 +939,10 @@ body {
|
|
| 930 |
min-height: 80px;
|
| 931 |
}
|
| 932 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 933 |
.w-10 {
|
| 934 |
width: 2.5rem;
|
| 935 |
}
|
|
@@ -1047,6 +1060,16 @@ body {
|
|
| 1047 |
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
| 1048 |
}
|
| 1049 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1050 |
.cursor-default {
|
| 1051 |
cursor: default;
|
| 1052 |
}
|
|
@@ -1289,6 +1312,11 @@ body {
|
|
| 1289 |
background-color: rgb(0 0 0 / 0.8);
|
| 1290 |
}
|
| 1291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1292 |
.bg-border {
|
| 1293 |
background-color: hsl(var(--border));
|
| 1294 |
}
|
|
@@ -1325,6 +1353,16 @@ body {
|
|
| 1325 |
background-color: hsl(var(--primary));
|
| 1326 |
}
|
| 1327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1328 |
.bg-secondary {
|
| 1329 |
background-color: hsl(var(--secondary));
|
| 1330 |
}
|
|
@@ -1475,6 +1513,11 @@ body {
|
|
| 1475 |
line-height: 2rem;
|
| 1476 |
}
|
| 1477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1478 |
.text-5xl {
|
| 1479 |
font-size: 3rem;
|
| 1480 |
line-height: 1;
|
|
@@ -1557,6 +1600,16 @@ body {
|
|
| 1557 |
color: hsl(var(--foreground) / 0.5);
|
| 1558 |
}
|
| 1559 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1560 |
.text-muted-foreground {
|
| 1561 |
color: hsl(var(--muted-foreground));
|
| 1562 |
}
|
|
@@ -1903,16 +1956,6 @@ body {
|
|
| 1903 |
}
|
| 1904 |
}
|
| 1905 |
|
| 1906 |
-
@keyframes rotate {
|
| 1907 |
-
from {
|
| 1908 |
-
transform: rotate(0deg);
|
| 1909 |
-
}
|
| 1910 |
-
|
| 1911 |
-
to {
|
| 1912 |
-
transform: rotate(360deg);
|
| 1913 |
-
}
|
| 1914 |
-
}
|
| 1915 |
-
|
| 1916 |
.animate-fade-in {
|
| 1917 |
animation: fade-in 1s ease-out forwards;
|
| 1918 |
}
|
|
@@ -1921,11 +1964,6 @@ body {
|
|
| 1921 |
animation: slide-up 1s ease-out forwards;
|
| 1922 |
}
|
| 1923 |
|
| 1924 |
-
.animate-rotate {
|
| 1925 |
-
animation: rotate 2s linear infinite;
|
| 1926 |
-
display: inline;
|
| 1927 |
-
}
|
| 1928 |
-
|
| 1929 |
.sim-map-button.active {
|
| 1930 |
background-color: #61D790;
|
| 1931 |
color: #2E2F27;
|
|
|
|
| 801 |
margin-bottom: 0.25rem;
|
| 802 |
}
|
| 803 |
|
| 804 |
+
.mr-1\.5 {
|
| 805 |
+
margin-right: 0.375rem;
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
.mt-2 {
|
| 809 |
margin-top: 0.5rem;
|
| 810 |
}
|
|
|
|
| 846 |
height: 1rem;
|
| 847 |
}
|
| 848 |
|
| 849 |
+
.size-5 {
|
| 850 |
+
width: 1.25rem;
|
| 851 |
+
height: 1.25rem;
|
| 852 |
+
}
|
| 853 |
+
|
| 854 |
.h-10 {
|
| 855 |
height: 2.5rem;
|
| 856 |
}
|
|
|
|
| 939 |
min-height: 80px;
|
| 940 |
}
|
| 941 |
|
| 942 |
+
.min-h-screen {
|
| 943 |
+
min-height: 100vh;
|
| 944 |
+
}
|
| 945 |
+
|
| 946 |
.w-10 {
|
| 947 |
width: 2.5rem;
|
| 948 |
}
|
|
|
|
| 1060 |
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
| 1061 |
}
|
| 1062 |
|
| 1063 |
+
@keyframes spin {
|
| 1064 |
+
to {
|
| 1065 |
+
transform: rotate(360deg);
|
| 1066 |
+
}
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
.animate-spin {
|
| 1070 |
+
animation: spin 1s linear infinite;
|
| 1071 |
+
}
|
| 1072 |
+
|
| 1073 |
.cursor-default {
|
| 1074 |
cursor: default;
|
| 1075 |
}
|
|
|
|
| 1312 |
background-color: rgb(0 0 0 / 0.8);
|
| 1313 |
}
|
| 1314 |
|
| 1315 |
+
.bg-blue-500 {
|
| 1316 |
+
--tw-bg-opacity: 1;
|
| 1317 |
+
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
| 1318 |
+
}
|
| 1319 |
+
|
| 1320 |
.bg-border {
|
| 1321 |
background-color: hsl(var(--border));
|
| 1322 |
}
|
|
|
|
| 1353 |
background-color: hsl(var(--primary));
|
| 1354 |
}
|
| 1355 |
|
| 1356 |
+
.bg-red-300 {
|
| 1357 |
+
--tw-bg-opacity: 1;
|
| 1358 |
+
background-color: rgb(252 165 165 / var(--tw-bg-opacity));
|
| 1359 |
+
}
|
| 1360 |
+
|
| 1361 |
+
.bg-red-500 {
|
| 1362 |
+
--tw-bg-opacity: 1;
|
| 1363 |
+
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
| 1364 |
+
}
|
| 1365 |
+
|
| 1366 |
.bg-secondary {
|
| 1367 |
background-color: hsl(var(--secondary));
|
| 1368 |
}
|
|
|
|
| 1513 |
line-height: 2rem;
|
| 1514 |
}
|
| 1515 |
|
| 1516 |
+
.text-3xl {
|
| 1517 |
+
font-size: 1.875rem;
|
| 1518 |
+
line-height: 2.25rem;
|
| 1519 |
+
}
|
| 1520 |
+
|
| 1521 |
.text-5xl {
|
| 1522 |
font-size: 3rem;
|
| 1523 |
line-height: 1;
|
|
|
|
| 1600 |
color: hsl(var(--foreground) / 0.5);
|
| 1601 |
}
|
| 1602 |
|
| 1603 |
+
.text-gray-800 {
|
| 1604 |
+
--tw-text-opacity: 1;
|
| 1605 |
+
color: rgb(31 41 55 / var(--tw-text-opacity));
|
| 1606 |
+
}
|
| 1607 |
+
|
| 1608 |
+
.text-gray-900 {
|
| 1609 |
+
--tw-text-opacity: 1;
|
| 1610 |
+
color: rgb(17 24 39 / var(--tw-text-opacity));
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
.text-muted-foreground {
|
| 1614 |
color: hsl(var(--muted-foreground));
|
| 1615 |
}
|
|
|
|
| 1956 |
}
|
| 1957 |
}
|
| 1958 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1959 |
.animate-fade-in {
|
| 1960 |
animation: fade-in 1s ease-out forwards;
|
| 1961 |
}
|
|
|
|
| 1964 |
animation: slide-up 1s ease-out forwards;
|
| 1965 |
}
|
| 1966 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1967 |
.sim-map-button.active {
|
| 1968 |
background-color: #61D790;
|
| 1969 |
color: #2E2F27;
|