Spaces:
Running
Running
Update App_Function_Libraries/DB/RAG_QA_Chat_DB.py
Browse files
App_Function_Libraries/DB/RAG_QA_Chat_DB.py
CHANGED
@@ -23,41 +23,56 @@ from App_Function_Libraries.Utils.Utils import get_project_relative_path, get_pr
|
|
23 |
########################################################################################################################
|
24 |
#
|
25 |
# Functions:
|
|
|
26 |
def get_rag_qa_db_path():
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
else:
|
56 |
-
print("
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
def check_config_file():
|
63 |
current_dir = os.getcwd()
|
|
|
23 |
########################################################################################################################
|
24 |
#
|
25 |
# Functions:
|
26 |
+
|
27 |
def get_rag_qa_db_path():
|
28 |
+
try:
|
29 |
+
config_path = os.path.join(get_project_root(), 'Config_Files', 'config.txt')
|
30 |
+
print(f"Attempting to read config from: {config_path}")
|
31 |
+
|
32 |
+
if not os.path.exists(config_path):
|
33 |
+
print(f"Config file does not exist at: {config_path}")
|
34 |
+
raise FileNotFoundError(f"Config file not found at: {config_path}")
|
35 |
+
|
36 |
+
config = configparser.ConfigParser()
|
37 |
+
files_read = config.read(config_path)
|
38 |
+
print(f"Config files read: {files_read}")
|
39 |
+
print(f"Sections in config: {config.sections()}")
|
40 |
+
|
41 |
+
if 'Database' in config.sections():
|
42 |
+
print("Found Database section")
|
43 |
+
print(f"Options in Database section: {config.options('Database')}")
|
44 |
+
|
45 |
+
if 'rag_qa_db_path' in config.options('Database'):
|
46 |
+
rag_qa_db_path = config.get('Database', 'rag_qa_db_path')
|
47 |
+
print(f"Found rag_qa_db_path: {rag_qa_db_path}")
|
48 |
+
|
49 |
+
if not os.path.isabs(rag_qa_db_path):
|
50 |
+
project_root = get_project_root()
|
51 |
+
rag_qa_db_path = os.path.join(project_root, rag_qa_db_path)
|
52 |
+
print(f"Converted to absolute path: {rag_qa_db_path}")
|
53 |
+
|
54 |
+
# Ensure the directory exists
|
55 |
+
db_dir = os.path.dirname(rag_qa_db_path)
|
56 |
+
if not os.path.exists(db_dir):
|
57 |
+
print(f"Creating directory: {db_dir}")
|
58 |
+
os.makedirs(db_dir, exist_ok=True)
|
59 |
+
|
60 |
+
return rag_qa_db_path
|
61 |
+
else:
|
62 |
+
print("rag_qa_db_path not found in Database section")
|
63 |
+
print(f"Available options: {config.options('Database')}")
|
64 |
else:
|
65 |
+
print("Database section not found in config")
|
66 |
+
print(f"Available sections: {config.sections()}")
|
67 |
+
|
68 |
+
raise ValueError("Database path not found in config file")
|
69 |
+
|
70 |
+
except Exception as e:
|
71 |
+
print(f"Error in get_rag_qa_db_path: {str(e)}")
|
72 |
+
print(f"Error type: {type(e)}")
|
73 |
+
import traceback
|
74 |
+
print(f"Traceback: {traceback.format_exc()}")
|
75 |
+
raise
|
76 |
|
77 |
def check_config_file():
|
78 |
current_dir = os.getcwd()
|