DiamondYin commited on
Commit
7f32613
1 Parent(s): 2b0f79c

Update app_utils.py

Browse files
Files changed (1) hide show
  1. app_utils.py +3 -3
app_utils.py CHANGED
@@ -14,7 +14,7 @@ from langchain.vectorstores import Chroma # Chroma is a class in the langchain.v
14
  from langchain.document_loaders import DirectoryLoader #
15
  from langchain.embeddings.openai import OpenAIEmbeddings # OpenAIGPTEmbeddings
16
  from langchain.text_splitter import CharacterTextSplitter # CharacterTextSplitter is a class in the langchain.text_splitter module that can be used to split text into chunks.
17
- from langchain.document import Document
18
 
19
  OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
20
  AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
@@ -46,8 +46,8 @@ def initialize_knowledge_base():
46
  embeddings = []
47
  openAI_embeddings = OpenAIEmbeddings()
48
  for text in doc_texts:
49
- doc = Document.from_text(text)
50
- embedding = Chroma.from_documents(doc, openAI_embeddings)
51
  embeddings.append(embedding)
52
 
53
  vStore = np.concatenate(embeddings, axis=0)
 
14
  from langchain.document_loaders import DirectoryLoader #
15
  from langchain.embeddings.openai import OpenAIEmbeddings # OpenAIGPTEmbeddings
16
  from langchain.text_splitter import CharacterTextSplitter # CharacterTextSplitter is a class in the langchain.text_splitter module that can be used to split text into chunks.
17
+
18
 
19
  OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
20
  AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
 
46
  embeddings = []
47
  openAI_embeddings = OpenAIEmbeddings()
48
  for text in doc_texts:
49
+ #doc = Document.from_text(text)
50
+ embedding = openAI_embeddings.embed(text)
51
  embeddings.append(embedding)
52
 
53
  vStore = np.concatenate(embeddings, axis=0)