LangChain 공식문서의 Chroma 사용 가이드 ↗️ 를 기준으로 보면 한줄만 변경하면 됨
# importfrom langchain_chroma import Chromafrom langchain_community.document_loaders import TextLoaderfrom langchain_community.embeddings.sentence_transformer import ( SentenceTransformerEmbeddings,)from langchain_text_splitters import CharacterTextSplitter# load the document and split it into chunksloader =TextLoader("../../how_to/state_of_the_union.txt")documents = loader.load()# split it into chunkstext_splitter =CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)# create the open-source embedding functionembedding_function =SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")# load it into Chromadb = PineconeVectorStore.from_documents(docs, embeddings, index_name=index_name)# query itquery ="What did the president say about Ketanji Brown Jackson"docs = db.similarity_search(query)# print resultsprint(docs[0].page_content)