File tree Expand file tree Collapse file tree 1 file changed +1
-12
lines changed
examples/langchain-chroma Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Original file line number Diff line number Diff line change 22import os
33from langchain .vectorstores import Chroma
44from langchain .embeddings import OpenAIEmbeddings
5- from langchain .text_splitter import RecursiveCharacterTextSplitter ,CharacterTextSplitter
65from langchain .llms import OpenAI
76from langchain .chains import VectorDBQA
8- from langchain .document_loaders import TextLoader
97
108base_path = os .environ .get ('OPENAI_API_BASE' , 'http://localhost:8080/v1' )
119
1210# Load and process the text
13- loader = TextLoader ('state_of_the_union.txt' )
14- documents = loader .load ()
15-
16- text_splitter = CharacterTextSplitter (chunk_size = 300 , chunk_overlap = 70 )
17- texts = text_splitter .split_documents (documents )
18-
19- # Embed and store the texts
20- # Supplying a persist_directory will store the embeddings on disk
21- persist_directory = 'db'
22-
2311embedding = OpenAIEmbeddings ()
12+ persist_directory = 'db'
2413
2514# Now we can load the persisted database from disk, and use it as normal.
2615vectordb = Chroma (persist_directory = persist_directory , embedding_function = embedding )
You can’t perform that action at this time.
0 commit comments