Spaces:
Sleeping
Sleeping
Update rag_agent.py
Browse files- rag_agent.py +8 -0
rag_agent.py
CHANGED
|
@@ -21,6 +21,13 @@ load_dotenv()
|
|
| 21 |
BNI_CSV_FILE = "bni_pearl_chapter.csv"
|
| 22 |
BNI_JSON_FILE = "bni_pearl_chapter.json"
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# 1️⃣ **Convert CSV to JSON for structured retrieval**
|
| 25 |
def convert_csv_to_json():
|
| 26 |
df = pd.read_csv(BNI_CSV_FILE)
|
|
@@ -35,6 +42,7 @@ def convert_csv_to_json():
|
|
| 35 |
if not os.path.exists(BNI_JSON_FILE):
|
| 36 |
convert_csv_to_json()
|
| 37 |
|
|
|
|
| 38 |
# 2️⃣ **Create a Vector Database for RAG**
|
| 39 |
vector_db = LanceDb(
|
| 40 |
table_name="bni_pearl",
|
|
|
|
| 21 |
BNI_CSV_FILE = "bni_pearl_chapter.csv"
|
| 22 |
BNI_JSON_FILE = "bni_pearl_chapter.json"
|
| 23 |
|
| 24 |
+
# Define the path to the structured BNI dataset (JSON file)
|
| 25 |
+
BNI_DATA_PATH = "bni_pearl_chapter.json"
|
| 26 |
+
|
| 27 |
+
# Ensure the JSON file exists
|
| 28 |
+
if not os.path.exists(BNI_DATA_PATH):
|
| 29 |
+
raise FileNotFoundError(f"❌ Error: The BNI data file {BNI_DATA_PATH} is missing.")
|
| 30 |
+
|
| 31 |
# 1️⃣ **Convert CSV to JSON for structured retrieval**
|
| 32 |
def convert_csv_to_json():
|
| 33 |
df = pd.read_csv(BNI_CSV_FILE)
|
|
|
|
| 42 |
if not os.path.exists(BNI_JSON_FILE):
|
| 43 |
convert_csv_to_json()
|
| 44 |
|
| 45 |
+
|
| 46 |
# 2️⃣ **Create a Vector Database for RAG**
|
| 47 |
vector_db = LanceDb(
|
| 48 |
table_name="bni_pearl",
|