Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,26 @@
|
|
| 1 |
from langchain.prompts.prompt import PromptTemplate
|
| 2 |
from langchain.llms import OpenAI
|
| 3 |
from langchain.chains import ChatVectorDBChain
|
|
|
|
| 4 |
import os
|
|
|
|
| 5 |
from typing import Optional, Tuple
|
| 6 |
import gradio as gr
|
| 7 |
import pickle
|
| 8 |
from threading import Lock
|
| 9 |
|
| 10 |
-
|
| 11 |
-
vectorstore = pickle.load(f)
|
| 12 |
|
| 13 |
-
print(vectorstore)
|
| 14 |
-
query = 'What is the benefit of investing in an ETF?'
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
|
| 19 |
You can assume the question about investing and the investment management industry.
|
|
|
|
| 1 |
from langchain.prompts.prompt import PromptTemplate
|
| 2 |
from langchain.llms import OpenAI
|
| 3 |
from langchain.chains import ChatVectorDBChain
|
| 4 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
| 5 |
import os
|
| 6 |
+
import FAISS
|
| 7 |
from typing import Optional, Tuple
|
| 8 |
import gradio as gr
|
| 9 |
import pickle
|
| 10 |
from threading import Lock
|
| 11 |
|
| 12 |
+
model_sbert = "sentence-transformers/all-mpnet-base-v2"
|
|
|
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
sbert_emb = HuggingFaceEmbeddings(model_name=model_sbert)
|
| 16 |
+
|
| 17 |
+
def load_vectorstore(folder,embeddings):
|
| 18 |
+
|
| 19 |
+
vectorstore = FAISS.load_local(folder,embeddings)
|
| 20 |
+
|
| 21 |
+
return vectorstore
|
| 22 |
+
|
| 23 |
+
vectorstore = load_vectorstore('vanguard-embeddings',sbert_emb)
|
| 24 |
|
| 25 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
|
| 26 |
You can assume the question about investing and the investment management industry.
|