Skip to content

Commit

Permalink
Add Milvus backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinzyx committed Aug 10, 2024
1 parent 0b19dfb commit 1345b59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env-Sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OPENAI_API_VERSION=2024-02-01
GOOGLE_API_KEY=AIzaSyDN2-XXXXXXXXX
GOOGLE_CLOUD_PROJECT=projectid
PGVECTOR_CONNECTION_STRING=postgresql+psycopg://langchain:langchain@localhost:6024/langchain
MILVUS_CONNECTION_STRING=http://localhost:19530 # ./milvus_demo.db
RUN_CONFIG_TIMEOUT=240
RUN_CONFIG_MAX_WORKERS=16
RUN_CONFIG_MAX_WAIT=180
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ langchain-google-genai
langchain-google-vertexai
langchain-ollama
langchain_postgres
psycopg[binary,pool]
psycopg[binary,pool]
langchain_milvus
2 changes: 1 addition & 1 deletion src/ragbuilder/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# Get the database URL from the environment variable
SINGLESTOREDB_URL = os.getenv("SINGLESTOREDB_URL")
PGVECTOR_CONNECTION_STRING = os.getenv("PGVECTOR_CONNECTION_STRING")

MILVUS_CONNECTION_STRING = os.getenv("MILVUS_CONNECTION_STRING")
import dotenv
from langchain_community.document_loaders import *
from langchain_text_splitters import *
Expand Down
7 changes: 7 additions & 0 deletions src/ragbuilder/langchain_module/vectordb/vectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
from langchain_postgres.vectorstores import PGVector
from langchain_pinecone import PineconeVectorStore
from pinecone import Pinecone, ServerlessSpec
from langchain_milvus import Milvus
import uuid
import time
from getpass import getpass
setup_logging()
logger = logging.getLogger("ragbuilder")

def getVectorDB(db_type,embedding_model):
db_type= "milvusDB"
"""
Initialize and return a vector database object based on the specified db_type.
Expand All @@ -38,6 +40,11 @@ def getVectorDB(db_type,embedding_model):
logger.info("FAISS DB Loaded")
code_string= f"""c=FAISS.from_documents(documents=splits, embedding=embedding)"""
import_string = f"""from langchain_community.vectorstores import FAISS"""
elif db_type == "milvusDB":
logger.info("Milvus DB Loaded")
code_string= f"""c = Milvus.from_documents(splits,embedding,collection_name='test',connection_args={{"uri": MILVUS_CONNECTION_STRING}},)"""
print(code_string)
import_string = f"""from langchain_milvus import Milvus"""
elif db_type == "singleStoreDB":
index_name = "testindex_ragbuilder"
logger.info("Singlestore DB Loaded")
Expand Down

0 comments on commit 1345b59

Please sign in to comment.