Spaces:
Sleeping
Sleeping
Commit
·
9abd4ea
1
Parent(s):
796eef1
bug
Browse files- knowledge_base.py +11 -7
knowledge_base.py
CHANGED
|
@@ -20,17 +20,21 @@ class KnowledgeBase:
|
|
| 20 |
self._build_initial_knowledge_base()
|
| 21 |
|
| 22 |
def _build_initial_knowledge_base(self):
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
]
|
|
|
|
| 28 |
documents_content = {}
|
| 29 |
-
for
|
|
|
|
| 30 |
try:
|
| 31 |
with open(file_path, 'r', encoding='utf-8') as f:
|
| 32 |
-
|
| 33 |
-
documents_content[os.path.basename(file_path)] = f.read()
|
| 34 |
except FileNotFoundError:
|
| 35 |
print(f"Warning: Knowledge base file not found, skipping: {file_path}")
|
| 36 |
|
|
|
|
| 20 |
self._build_initial_knowledge_base()
|
| 21 |
|
| 22 |
def _build_initial_knowledge_base(self):
|
| 23 |
+
current_dir = os.path.dirname(__file__)
|
| 24 |
+
knowledge_base_data_dir = os.path.join(current_dir, "knowledge_base_data")
|
| 25 |
+
|
| 26 |
+
document_filenames = [
|
| 27 |
+
"healthy_maize_remedy.txt",
|
| 28 |
+
"maize_phosphorus_deficiency_remedy.txt",
|
| 29 |
+
"comic_relief.txt"
|
| 30 |
]
|
| 31 |
+
|
| 32 |
documents_content = {}
|
| 33 |
+
for filename in document_filenames:
|
| 34 |
+
file_path = os.path.join(knowledge_base_data_dir, filename)
|
| 35 |
try:
|
| 36 |
with open(file_path, 'r', encoding='utf-8') as f:
|
| 37 |
+
documents_content[filename] = f.read()
|
|
|
|
| 38 |
except FileNotFoundError:
|
| 39 |
print(f"Warning: Knowledge base file not found, skipping: {file_path}")
|
| 40 |
|