Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from langchain_community.document_loaders.url import UnstructuredURLLoader
|
| 4 |
-
from langchain_community.embeddings import HuggingFaceHubEmbeddings
|
| 5 |
from langchain_huggingface.embeddings import HuggingFaceEndpointEmbeddings
|
| 6 |
from langchain_community.vectorstores.faiss import FAISS
|
| 7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
@@ -69,7 +68,7 @@ if process_url_clicked:
|
|
| 69 |
query = main_placeholder.text_input("Question: ")
|
| 70 |
if query:
|
| 71 |
if os.path.exists(faiss_index_path):
|
| 72 |
-
embeddings =
|
| 73 |
vectorstore = load_faiss_index(faiss_index_path, embeddings)
|
| 74 |
chain = RetrievalQAWithSourcesChain.from_llm(llm=llm, retriever=vectorstore.as_retriever())
|
| 75 |
result = chain({"question": query}, return_only_outputs=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from langchain_community.document_loaders.url import UnstructuredURLLoader
|
|
|
|
| 4 |
from langchain_huggingface.embeddings import HuggingFaceEndpointEmbeddings
|
| 5 |
from langchain_community.vectorstores.faiss import FAISS
|
| 6 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
|
|
| 68 |
query = main_placeholder.text_input("Question: ")
|
| 69 |
if query:
|
| 70 |
if os.path.exists(faiss_index_path):
|
| 71 |
+
embeddings = HuggingFaceEndpointEmbeddings(huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN"))
|
| 72 |
vectorstore = load_faiss_index(faiss_index_path, embeddings)
|
| 73 |
chain = RetrievalQAWithSourcesChain.from_llm(llm=llm, retriever=vectorstore.as_retriever())
|
| 74 |
result = chain({"question": query}, return_only_outputs=True)
|