Spaces:
Runtime error
Runtime error
Commit
·
550e253
1
Parent(s):
bd57dbf
Update app_utils.py
Browse files- app_utils.py +4 -3
app_utils.py
CHANGED
@@ -13,6 +13,7 @@ from langchain.chains import RetrievalQA # RetrievalQA is a class in the langch
|
|
13 |
from langchain.vectorstores import Chroma # Chroma is a class in the langchain.vectorstores module that can be used to store vectors.
|
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 |
#import streamlit as st
|
18 |
from langchain.indexes import VectorstoreIndexCreator #导入向量存储索引创建器
|
@@ -75,9 +76,9 @@ def initialize_knowledge_base():
|
|
75 |
# embeddings.append(embedding)
|
76 |
|
77 |
#vStore = np.concatenate(embeddings, axis=0)
|
78 |
-
|
79 |
-
openAI_embeddings = OpenAIEmbeddings()
|
80 |
-
vStore = Chroma.from_documents(doc_texts,
|
81 |
|
82 |
conv_model = RetrievalQA.from_chain_type(
|
83 |
llm=OpenAI(model_name="gpt-3.5-turbo-16k"),
|
|
|
13 |
from langchain.vectorstores import Chroma # Chroma is a class in the langchain.vectorstores module that can be used to store vectors.
|
14 |
from langchain.document_loaders import DirectoryLoader #
|
15 |
from langchain.embeddings.openai import OpenAIEmbeddings # OpenAIGPTEmbeddings
|
16 |
+
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
17 |
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.
|
18 |
#import streamlit as st
|
19 |
from langchain.indexes import VectorstoreIndexCreator #导入向量存储索引创建器
|
|
|
76 |
# embeddings.append(embedding)
|
77 |
|
78 |
#vStore = np.concatenate(embeddings, axis=0)
|
79 |
+
embedding = HuggingFaceInstructEmbeddings()
|
80 |
+
#openAI_embeddings = OpenAIEmbeddings()
|
81 |
+
vStore = Chroma.from_documents(doc_texts, embedding) #Chroma是一个类,用于存储向量,from_documents是一个方法,用于从文档中创建向量存储器,openAI_embeddings是一个类,用于将文本转换为向量
|
82 |
|
83 |
conv_model = RetrievalQA.from_chain_type(
|
84 |
llm=OpenAI(model_name="gpt-3.5-turbo-16k"),
|