Spaces:
Running
Running
Ashmi Banerjee
commited on
Commit
•
e79d81c
1
Parent(s):
4b722ec
moved the app.py
Browse files- README.md +9 -0
- src/app.py → app.py +0 -0
- src/vectordb/vectordb.py +9 -5
README.md
CHANGED
@@ -11,3 +11,12 @@ license: mit
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
|
16 |
+
### TODOs
|
17 |
+
|
18 |
+
[x] Refactor the vectordb.py - remove code duplication
|
19 |
+
[x] Sustainability - database paths - move to HF
|
20 |
+
[x] Fix it for the new models e.g. Llama and others
|
21 |
+
[x] Add the space secrets to have it running online
|
22 |
+
[x] Make the space public
|
src/app.py → app.py
RENAMED
File without changes
|
src/vectordb/vectordb.py
CHANGED
@@ -88,6 +88,7 @@ def search_wikivoyage_docs(query: str, limit: int = 10, reranking: int = 0, run_
|
|
88 |
logger.error(f"Error while connecting to DB: {e}")
|
89 |
|
90 |
logger.info("Connected to Wikivoyage DB.")
|
|
|
91 |
|
92 |
# query_embedding = embed_query(query)
|
93 |
table = db.open_table("wikivoyage_documents")
|
@@ -126,7 +127,7 @@ def search_wikivoyage_docs(query: str, limit: int = 10, reranking: int = 0, run_
|
|
126 |
return city_lists
|
127 |
|
128 |
|
129 |
-
def search_wikivoyage_listings(query, cities, limit=10, reranking=0):
|
130 |
"""
|
131 |
|
132 |
Function to search the wikivoyage database an return most relevant listings, post-filtered by the recommended
|
@@ -139,11 +140,14 @@ def search_wikivoyage_listings(query, cities, limit=10, reranking=0):
|
|
139 |
- reranking: bool (0 or 1), if activated, CrossEncoderReranker is used.
|
140 |
|
141 |
"""
|
142 |
-
|
143 |
-
|
|
|
144 |
|
145 |
-
|
146 |
-
|
|
|
|
|
147 |
|
148 |
db = lancedb.connect(uri)
|
149 |
logger.info("Connected to Wikivoyage Listings DB.")
|
|
|
88 |
logger.error(f"Error while connecting to DB: {e}")
|
89 |
|
90 |
logger.info("Connected to Wikivoyage DB.")
|
91 |
+
print("Tablenames: ", db.table_names())
|
92 |
|
93 |
# query_embedding = embed_query(query)
|
94 |
table = db.open_table("wikivoyage_documents")
|
|
|
127 |
return city_lists
|
128 |
|
129 |
|
130 |
+
def search_wikivoyage_listings(query:str, cities: list, limit: int=10, reranking: int = 0, run_local: Optional[bool] = False):
|
131 |
"""
|
132 |
|
133 |
Function to search the wikivoyage database an return most relevant listings, post-filtered by the recommended
|
|
|
140 |
- reranking: bool (0 or 1), if activated, CrossEncoderReranker is used.
|
141 |
|
142 |
"""
|
143 |
+
if run_local:
|
144 |
+
uri = database_dir
|
145 |
+
current_dir = os.path.split(os.getcwd())[1]
|
146 |
|
147 |
+
if "src" or "tests" in current_dir: # hacky way to get the correct path
|
148 |
+
uri = uri.replace("../../", "../")
|
149 |
+
else:
|
150 |
+
uri = os.environ["BUCKET_NAME"]
|
151 |
|
152 |
db = lancedb.connect(uri)
|
153 |
logger.info("Connected to Wikivoyage Listings DB.")
|