Spaces:
Running
Running
oceansweep
commited on
Commit
•
c7e3317
1
Parent(s):
2d5d335
Update App_Function_Libraries/DB/RAG_QA_Chat_DB.py
Browse files
App_Function_Libraries/DB/RAG_QA_Chat_DB.py
CHANGED
@@ -24,47 +24,58 @@ from App_Function_Libraries.Utils.Utils import get_project_relative_path, get_pr
|
|
24 |
#
|
25 |
# Functions:
|
26 |
def get_rag_qa_db_path():
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
config = configparser.ConfigParser()
|
35 |
|
36 |
-
#
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
logging.error("No config files were successfully read")
|
42 |
-
raise ValueError("No config files were successfully read")
|
43 |
-
except Exception as e:
|
44 |
-
logging.error(f"Error reading config file: {str(e)}")
|
45 |
-
raise
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
if config.has_section('Database'):
|
51 |
-
|
52 |
-
logging.info(f"Available options in Database section: {config.options('Database')}")
|
53 |
-
|
54 |
if config.has_option('Database', 'rag_qa_db_path'):
|
55 |
rag_qa_db_path = config.get('Database', 'rag_qa_db_path')
|
56 |
-
|
57 |
-
|
58 |
if not os.path.isabs(rag_qa_db_path):
|
59 |
rag_qa_db_path = get_project_relative_path(rag_qa_db_path)
|
60 |
-
logging.info(f"Converted to absolute path: {rag_qa_db_path}")
|
61 |
return rag_qa_db_path
|
62 |
else:
|
63 |
-
|
64 |
-
raise ValueError("Database path not found in config file")
|
65 |
else:
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# Set up logging
|
70 |
logging.basicConfig(level=logging.INFO)
|
|
|
24 |
#
|
25 |
# Functions:
|
26 |
def get_rag_qa_db_path():
|
27 |
+
# Get and verify project root
|
28 |
+
project_root = get_project_root()
|
29 |
+
print(f"Project root path: {project_root}")
|
30 |
|
31 |
+
# Construct and verify config path
|
32 |
+
config_path = os.path.join(project_root, 'Config_Files', 'config.txt')
|
33 |
+
print(f"Looking for config at: {config_path}")
|
34 |
+
print(f"Config file exists: {os.path.exists(config_path)}")
|
|
|
|
|
35 |
|
36 |
+
# If config exists, check its contents
|
37 |
+
if os.path.exists(config_path):
|
38 |
+
with open(config_path, 'r') as f:
|
39 |
+
print("Raw config contents:")
|
40 |
+
print(f.read())
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
config = configparser.ConfigParser()
|
43 |
+
files_read = config.read(config_path)
|
44 |
+
print(f"Files successfully read: {files_read}")
|
45 |
+
print(f"Available sections: {config.sections()}")
|
46 |
|
47 |
if config.has_section('Database'):
|
48 |
+
print(f"Database section options: {config.options('Database')}")
|
|
|
|
|
49 |
if config.has_option('Database', 'rag_qa_db_path'):
|
50 |
rag_qa_db_path = config.get('Database', 'rag_qa_db_path')
|
51 |
+
print(f"Found rag_qa_db_path: {rag_qa_db_path}")
|
|
|
52 |
if not os.path.isabs(rag_qa_db_path):
|
53 |
rag_qa_db_path = get_project_relative_path(rag_qa_db_path)
|
|
|
54 |
return rag_qa_db_path
|
55 |
else:
|
56 |
+
print("rag_qa_db_path option not found in Database section")
|
|
|
57 |
else:
|
58 |
+
print("Database section not found")
|
59 |
+
|
60 |
+
raise ValueError("Database path not found in config file")
|
61 |
+
|
62 |
+
def check_config_file():
|
63 |
+
current_dir = os.getcwd()
|
64 |
+
print(f"Current working directory: {current_dir}")
|
65 |
+
|
66 |
+
# List files in current directory
|
67 |
+
print("\nFiles in current directory:")
|
68 |
+
for item in os.listdir(current_dir):
|
69 |
+
print(item)
|
70 |
+
|
71 |
+
# Check Config_Files directory if it exists
|
72 |
+
config_dir = os.path.join(current_dir, 'Config_Files')
|
73 |
+
if os.path.exists(config_dir):
|
74 |
+
print("\nFiles in Config_Files directory:")
|
75 |
+
for item in os.listdir(config_dir):
|
76 |
+
print(item)
|
77 |
+
|
78 |
+
check_config_file()
|
79 |
|
80 |
# Set up logging
|
81 |
logging.basicConfig(level=logging.INFO)
|