mirror of
https://github.com/SirBlobby/Hoya26.git
synced 2026-02-04 11:44:34 -05:00
Code Update
This commit is contained in:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user