Skip to content

Commit

Permalink
chore: update vector index script to use config
Browse files Browse the repository at this point in the history
  • Loading branch information
leggetter committed Sep 19, 2024
1 parent 20d528f commit 2b73b90
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions create-vector-index.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# Inspiration https://www.mongodb.com/developer/products/atlas/how-use-cohere-embeddings-rerank-modules-mongodb-atlas/#programmatically-create-vector-search-and-full-text-search-index

from config import Config
from lib.mongo import get_mongo_client
from pymongo.operations import SearchIndexModel
from dotenv import load_dotenv

load_dotenv()

DB_NAME = "iaat"
COLLECTION_NAME = "assets"

# Connect to your Atlas deployment
client = get_mongo_client()
if client is None:
raise Exception("Failed to connect to MongoDB")

# Access your database and collection
database = client[DB_NAME]
collection = database[COLLECTION_NAME]
database = client[Config.DB_NAME]
collection = database[Config.COLLECTION_NAME]

# Create your index model, then create the search index
search_index_model = SearchIndexModel(
Expand Down

0 comments on commit 2b73b90

Please sign in to comment.