Spaces:
Running
Running
thenativefox
commited on
Commit
·
bd075c2
1
Parent(s):
01a0078
attempt4
Browse files- backend/semantic_search.py +12 -20
backend/semantic_search.py
CHANGED
@@ -14,25 +14,17 @@ logger = logging.getLogger(__name__)
|
|
14 |
load_dotenv()
|
15 |
|
16 |
# Connect to the LanceDB database
|
17 |
-
# Determine the working directory
|
18 |
current_working_dir = Path(os.getcwd())
|
19 |
-
|
20 |
-
|
21 |
-
# List contents of the current working directory
|
22 |
-
current_dir_contents = os.listdir(current_working_dir)
|
23 |
-
logger.info(f"Contents of the working directory: {current_dir_contents}")
|
24 |
-
|
25 |
-
# Ensure the working directory contains 'gradio_app'
|
26 |
-
if 'gradio_app' not in current_dir_contents:
|
27 |
-
raise FileNotFoundError("The 'gradio_app' directory is missing from the working directory.")
|
28 |
-
|
29 |
-
# List and log all contents of the gradio_app directory
|
30 |
-
gradio_app_dir = current_working_dir / 'gradio_app'
|
31 |
-
gradio_app_contents = os.listdir(gradio_app_dir)
|
32 |
-
logger.info(f"Contents of 'gradio_app' directory: {gradio_app_contents}")
|
33 |
-
|
34 |
-
db_path = current_working_dir / "gradio_app" / ".lancedb"
|
35 |
logger.info(f"Database path: {db_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
db = lancedb.connect(db_path)
|
37 |
|
38 |
MODEL1_STRATEGY1 = "model1_fixed"
|
@@ -70,6 +62,6 @@ def retrieve(query, k):
|
|
70 |
except Exception as e:
|
71 |
raise gr.Error(str(e))
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
14 |
load_dotenv()
|
15 |
|
16 |
# Connect to the LanceDB database
|
|
|
17 |
current_working_dir = Path(os.getcwd())
|
18 |
+
# Determine the LanceDB path and log it
|
19 |
+
db_path = current_working_dir / ".lancedb"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
logger.info(f"Database path: {db_path}")
|
21 |
+
|
22 |
+
# List contents of the LanceDB directory
|
23 |
+
if db_path.exists():
|
24 |
+
lancedb_contents = os.listdir(db_path)
|
25 |
+
logger.info(f"Contents of the LanceDB directory: {lancedb_contents}")
|
26 |
+
else:
|
27 |
+
logger.error(f"LanceDB directory does not exist at path: {db_path}")
|
28 |
db = lancedb.connect(db_path)
|
29 |
|
30 |
MODEL1_STRATEGY1 = "model1_fixed"
|
|
|
62 |
except Exception as e:
|
63 |
raise gr.Error(str(e))
|
64 |
|
65 |
+
if __name__ == "__main__":
|
66 |
+
res = retrieve("What is transformer?", 4)
|
67 |
+
print(res)
|