dinhquangson commited on
Commit
cea66bb
1 Parent(s): 8fd584d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -15,6 +15,11 @@ import uuid
15
  from qdrant_client import models, QdrantClient
16
  from itertools import islice
17
 
 
 
 
 
 
18
  app = FastAPI()
19
 
20
 
@@ -144,6 +149,40 @@ async def download_database():
144
 
145
  # Return the zip file as a response for download
146
  return FileResponse(zip_path, media_type='application/zip', filename='database.zip')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  @app.get("/")
149
  def api_home():
 
15
  from qdrant_client import models, QdrantClient
16
  from itertools import islice
17
 
18
+ # The file where NeuralSearcher is stored
19
+ from neural_searcher import NeuralSearcher
20
+ # The file where HybridSearcher is stored
21
+ from hybrid_searcher import HybridSearcher
22
+
23
  app = FastAPI()
24
 
25
 
 
149
 
150
  # Return the zip file as a response for download
151
  return FileResponse(zip_path, media_type='application/zip', filename='database.zip')
152
+
153
+ @app.get("/neural_search")
154
+ def neural_search(q: str, city: str, collection_name: str):
155
+ import time
156
+
157
+ start_time = time.time()
158
+
159
+ # Create a neural searcher instance
160
+ neural_searcher = NeuralSearcher(collection_name=collection_name)
161
+
162
+ end_time = time.time()
163
+
164
+ elapsed_time = end_time - start_time
165
+
166
+ print(f"Execution time: {elapsed_time:.6f} seconds")
167
+
168
+ return {"result": neural_searcher.search(text=q, city=city)}
169
+
170
+ @app.get("/hybrid_search")
171
+ def hybrid_search(q: str, city: str, collection_name: str):
172
+ import time
173
+
174
+ start_time = time.time()
175
+
176
+ # Create a hybrid searcher instance
177
+ hybrid_searcher = HybridSearcher(collection_name=collection_name)
178
+
179
+ end_time = time.time()
180
+
181
+ elapsed_time = end_time - start_time
182
+
183
+ print(f"Execution time: {elapsed_time:.6f} seconds")
184
+
185
+ return {"result": hybrid_searcher.search(text=q, city=city)}
186
 
187
  @app.get("/")
188
  def api_home():