Upload langchain_KB.py
Browse files- langchain_KB.py +1 -1
langchain_KB.py
CHANGED
@@ -97,7 +97,7 @@ def langchain_localKB_construct(filepath, username):
|
|
97 |
def langchain_RAG(prompt, username):
|
98 |
### 用langchain看框架接入本地知识库。
|
99 |
embeddings = OpenAIEmbeddings(disallowed_special=()) ## load embedding model again here.
|
100 |
-
vector_store = FAISS.load_local(f'./{username}/faiss_index', embeddings)
|
101 |
docs = vector_store.similarity_search(prompt, k=5)
|
102 |
context = [doc.page_content for doc in docs]
|
103 |
total_prompt = f"已知信息:\n{context}\n 根据这些已知信息来回答问题:\n{prompt}"
|
|
|
97 |
def langchain_RAG(prompt, username):
|
98 |
### 用langchain看框架接入本地知识库。
|
99 |
embeddings = OpenAIEmbeddings(disallowed_special=()) ## load embedding model again here.
|
100 |
+
vector_store = FAISS.load_local(f'./{username}/faiss_index', embeddings, allow_dangerous_deserialization=True)
|
101 |
docs = vector_store.similarity_search(prompt, k=5)
|
102 |
context = [doc.page_content for doc in docs]
|
103 |
total_prompt = f"已知信息:\n{context}\n 根据这些已知信息来回答问题:\n{prompt}"
|