forked from souvikmajumder26/Multi-Agent-Medical-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingest_rag_data.py
62 lines (44 loc) · 1.5 KB
/
ingest_rag_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
56
57
58
59
60
61
62
import warnings
warnings.filterwarnings('ignore')
import logging
import json
from pathlib import Path
import sys
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Add project root to path if needed
sys.path.append(str(Path(__file__).parent.parent))
# Import your components
from agents.rag_agent import MedicalRAG
from config import Config
import argparse
# Initialize parser
parser = argparse.ArgumentParser(description="Process some command-line arguments.")
# Add arguments
parser.add_argument("--file", type=str, required=False, help="Enter file path to ingest")
parser.add_argument("--dir", type=str, required=False, help="Enter directory path of files to ingest")
# Parse arguments
args = parser.parse_args()
# Load configuration
config = Config()
rag = MedicalRAG(config)
# document ingestion
def data_ingestion():
if args.file:
# Define path to file
file_path = args.file
# Process and ingest the file
result = rag.ingest_file(file_path)
elif args.dir:
# Define path to dir
dir_path = args.dir
# Process and ingest the files
result = rag.ingest_directory(dir_path)
print("Ingestion result:", json.dumps(result, indent=2))
return result["success"]
# Run tests
if __name__ == "__main__":
print("\nIngesting document(s)...")
ingestion_success = data_ingestion()
if ingestion_success:
print("\nSuccessfully ingested the documents.")