Spaces:
Running
on
T4
Running
on
T4
thomasht86
commited on
Upload folder using huggingface_hub
Browse files- frontend/app.py +3 -4
- main.py +10 -10
frontend/app.py
CHANGED
@@ -187,9 +187,7 @@ def Search(request, search_results=[]):
|
|
187 |
Div(
|
188 |
LoadingMessage(),
|
189 |
id="search-results", # This will be replaced by the search results
|
190 |
-
)
|
191 |
-
if not search_results
|
192 |
-
else SearchResult(search_results),
|
193 |
cls="grid",
|
194 |
),
|
195 |
cls="grid",
|
@@ -221,7 +219,8 @@ def SimMapButtonPoll(query_id, idx, token):
|
|
221 |
size="sm",
|
222 |
disabled=True,
|
223 |
hx_get=f"/get_sim_map?query_id={query_id}&idx={idx}&token={token}",
|
224 |
-
|
|
|
225 |
hx_swap="outerHTML",
|
226 |
)
|
227 |
|
|
|
187 |
Div(
|
188 |
LoadingMessage(),
|
189 |
id="search-results", # This will be replaced by the search results
|
190 |
+
),
|
|
|
|
|
191 |
cls="grid",
|
192 |
),
|
193 |
cls="grid",
|
|
|
219 |
size="sm",
|
220 |
disabled=True,
|
221 |
hx_get=f"/get_sim_map?query_id={query_id}&idx={idx}&token={token}",
|
222 |
+
# Poll every x seconds, where x is 0.3 x idx, formatted to 2 decimals
|
223 |
+
hx_trigger=f"every {(idx+1)*0.3:.2f}s",
|
224 |
hx_swap="outerHTML",
|
225 |
)
|
226 |
|
main.py
CHANGED
@@ -101,11 +101,11 @@ def get(request):
|
|
101 |
# Generate a unique query_id based on the query and ranking value
|
102 |
query_id = generate_query_id(query_value + ranking_value)
|
103 |
# See if results are already in cache
|
104 |
-
if result_cache.get(query_id) is not None:
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
# Show the loading message if a query is provided
|
110 |
return Layout(Search(request)) # Show SearchBox and Loading message initially
|
111 |
|
@@ -123,11 +123,11 @@ async def get(request, query: str, nn: bool = True):
|
|
123 |
# Generate a unique query_id based on the query and ranking value
|
124 |
query_id = generate_query_id(query + ranking_value)
|
125 |
# See if results are already in cache
|
126 |
-
if result_cache.get(query_id) is not None:
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
# Run the embedding and query against Vespa app
|
132 |
task_cache.set(query_id, False)
|
133 |
model = app.manager.model
|
|
|
101 |
# Generate a unique query_id based on the query and ranking value
|
102 |
query_id = generate_query_id(query_value + ranking_value)
|
103 |
# See if results are already in cache
|
104 |
+
# if result_cache.get(query_id) is not None:
|
105 |
+
# print(f"Results for query_id {query_id} already in cache")
|
106 |
+
# result = result_cache.get(query_id)
|
107 |
+
# search_results = get_results_children(result)
|
108 |
+
# return Layout(Search(request, search_results))
|
109 |
# Show the loading message if a query is provided
|
110 |
return Layout(Search(request)) # Show SearchBox and Loading message initially
|
111 |
|
|
|
123 |
# Generate a unique query_id based on the query and ranking value
|
124 |
query_id = generate_query_id(query + ranking_value)
|
125 |
# See if results are already in cache
|
126 |
+
# if result_cache.get(query_id) is not None:
|
127 |
+
# print(f"Results for query_id {query_id} already in cache")
|
128 |
+
# result = result_cache.get(query_id)
|
129 |
+
# search_results = get_results_children(result)
|
130 |
+
# return SearchResult(search_results, query_id)
|
131 |
# Run the embedding and query against Vespa app
|
132 |
task_cache.set(query_id, False)
|
133 |
model = app.manager.model
|