Spaces:
Running
Running
oceansweep
commited on
Commit
•
8a18d2a
1
Parent(s):
830d6c0
Update App_Function_Libraries/DB/RAG_QA_Chat_DB.py
Browse files
App_Function_Libraries/DB/RAG_QA_Chat_DB.py
CHANGED
@@ -28,10 +28,11 @@ 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 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
config = configparser.ConfigParser()
|
37 |
files_read = config.read(config_path)
|
@@ -42,6 +43,11 @@ def get_rag_qa_db_path():
|
|
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}")
|
@@ -51,19 +57,9 @@ def get_rag_qa_db_path():
|
|
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 |
|
@@ -74,23 +70,6 @@ def get_rag_qa_db_path():
|
|
74 |
print(f"Traceback: {traceback.format_exc()}")
|
75 |
raise
|
76 |
|
77 |
-
def check_config_file():
|
78 |
-
current_dir = os.getcwd()
|
79 |
-
print(f"Current working directory: {current_dir}")
|
80 |
-
|
81 |
-
# List files in current directory
|
82 |
-
print("\nFiles in current directory:")
|
83 |
-
for item in os.listdir(current_dir):
|
84 |
-
print(item)
|
85 |
-
|
86 |
-
# Check Config_Files directory if it exists
|
87 |
-
config_dir = os.path.join(current_dir, 'Config_Files')
|
88 |
-
if os.path.exists(config_dir):
|
89 |
-
print("\nFiles in Config_Files directory:")
|
90 |
-
for item in os.listdir(config_dir):
|
91 |
-
print(item)
|
92 |
-
|
93 |
-
check_config_file()
|
94 |
|
95 |
# Set up logging
|
96 |
logging.basicConfig(level=logging.INFO)
|
|
|
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 |
+
config.read(config_path, encoding='utf-8')
|
32 |
+
# Print the actual content of the file being read
|
33 |
+
with open(config_path, 'r') as f:
|
34 |
+
print("Raw config file contents:")
|
35 |
+
print(f.read())
|
36 |
|
37 |
config = configparser.ConfigParser()
|
38 |
files_read = config.read(config_path)
|
|
|
43 |
print("Found Database section")
|
44 |
print(f"Options in Database section: {config.options('Database')}")
|
45 |
|
46 |
+
# Try to get all values in the Database section
|
47 |
+
print("All values in Database section:")
|
48 |
+
for key in config['Database']:
|
49 |
+
print(f"{key} = {config['Database'][key]}")
|
50 |
+
|
51 |
if 'rag_qa_db_path' in config.options('Database'):
|
52 |
rag_qa_db_path = config.get('Database', 'rag_qa_db_path')
|
53 |
print(f"Found rag_qa_db_path: {rag_qa_db_path}")
|
|
|
57 |
rag_qa_db_path = os.path.join(project_root, rag_qa_db_path)
|
58 |
print(f"Converted to absolute path: {rag_qa_db_path}")
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
return rag_qa_db_path
|
61 |
else:
|
62 |
print("rag_qa_db_path not found in Database section")
|
|
|
|
|
|
|
|
|
63 |
|
64 |
raise ValueError("Database path not found in config file")
|
65 |
|
|
|
70 |
print(f"Traceback: {traceback.format_exc()}")
|
71 |
raise
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Set up logging
|
75 |
logging.basicConfig(level=logging.INFO)
|