thenativefox commited on
Commit
a7432c6
·
1 Parent(s): c44b083

second attempt to get path

Browse files
Files changed (1) hide show
  1. backend/semantic_search.py +11 -6
backend/semantic_search.py CHANGED
@@ -4,15 +4,20 @@ import gradio as gr
4
  from sentence_transformers import SentenceTransformer
5
  from pathlib import Path
6
  from dotenv import load_dotenv
 
 
 
 
 
7
 
8
  # Load environment variables from the .env file
9
  load_dotenv()
10
 
11
- print(f"Current Working Directory: {os.getcwd()}")
12
-
13
  # Connect to the LanceDB database
14
  current_working_dir = Path(os.getcwd())
15
- db_path = current_working_dir / ".lancedb"
 
 
16
  db = lancedb.connect(db_path)
17
 
18
  MODEL1_STRATEGY1 = "model1_fixed"
@@ -50,6 +55,6 @@ def retrieve(query, k):
50
  except Exception as e:
51
  raise gr.Error(str(e))
52
 
53
- if __name__ == "__main__":
54
- res = retrieve("What is transformer?", 4)
55
- print(res)
 
4
  from sentence_transformers import SentenceTransformer
5
  from pathlib import Path
6
  from dotenv import load_dotenv
7
+ import logging
8
+
9
+ # Set up logging
10
+ logging.basicConfig(level=logging.INFO)
11
+ logger = logging.getLogger(__name__)
12
 
13
  # Load environment variables from the .env file
14
  load_dotenv()
15
 
 
 
16
  # Connect to the LanceDB database
17
  current_working_dir = Path(os.getcwd())
18
+ logger.info(f"Working directory: {current_working_dir}")
19
+ db_path = current_working_dir / "gradio_app" / ".lancedb"
20
+ logger.info(f"Database path: {db_path}")
21
  db = lancedb.connect(db_path)
22
 
23
  MODEL1_STRATEGY1 = "model1_fixed"
 
55
  except Exception as e:
56
  raise gr.Error(str(e))
57
 
58
+ # if __name__ == "__main__":
59
+ # res = retrieve("What is transformer?", 4)
60
+ # print(res)