File size: 729 Bytes
10399f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# utils/doc_ingest.py
from .chat_rag import pdf_to_vec

def ingest_document(file_location: str, user_id: str):
    """
    Process and ingest a document into a user-specific vector database.
    
    :param file_location: The location of the uploaded file on the server.
    :param user_id: The ID of the user uploading the document.
    """
    # Construct a unique collection name based on user_id
    collection_name = f"user_{user_id}_collection"
    
    try:
        vectordb = pdf_to_vec(file_location, collection_name)
        print("Document processed and ingested successfully into user-specific collection.")
    except Exception as e:
        print(f"Error processing document for user {user_id}: {e}")
        raise