Code Update

This commit is contained in:
2026-01-24 04:01:05 +00:00
parent c87279ed52
commit aad7e6e08d
13 changed files with 18 additions and 469 deletions

View File

@@ -9,14 +9,10 @@ def get_mongo_client():
return MongoClient(uri)
def ingest_documents(text_chunks, collection_name="rag_documents"):
"""
Generates embeddings for text chunks and stores them in MongoDB.
"""
client = get_mongo_client()
db = client.get_database("vectors_db") # Default DB name
db = client.get_database("vectors_db")
collection = db[collection_name]
# Generate embeddings in batches (handling API limits might be needed for large sets)
embeddings = get_embeddings_batch(text_chunks)
documents = []
@@ -32,10 +28,6 @@ def ingest_documents(text_chunks, collection_name="rag_documents"):
return 0
def vector_search(query_text, collection_name="rag_documents", num_results=5):
"""
Performs a vector search in MongoDB.
"""
# 1. Get embedding for the query
from .embeddings import get_embedding
query_embedding = get_embedding(query_text)
@@ -43,7 +35,6 @@ def vector_search(query_text, collection_name="rag_documents", num_results=5):
db = client.get_database("vectors_db")
collection = db[collection_name]
# Note: You must have a vector search index defined in MongoDB Atlas for this to work.
pipeline = [
{
"$vectorSearch": {