Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,23 +8,23 @@ from io import BytesIO
|
|
| 8 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
|
| 9 |
from reportlab.lib.styles import getSampleStyleSheet
|
| 10 |
from reportlab.lib import colors
|
| 11 |
-
from
|
| 12 |
from langchain.embeddings import HuggingFaceEmbeddings
|
| 13 |
from langchain.document_loaders import DataFrameLoader
|
| 14 |
from langchain.chains import RetrievalQA
|
| 15 |
from langchain.llms import HuggingFaceHub
|
| 16 |
-
import os
|
| 17 |
|
| 18 |
-
# Retrieve
|
| 19 |
hf_api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 20 |
if not hf_api_key:
|
| 21 |
st.error("Hugging Face API key is not set. Please configure it in the secret settings.")
|
| 22 |
|
| 23 |
-
# Initialize Hugging Face model
|
| 24 |
llm = HuggingFaceHub(
|
| 25 |
repo_id="google/flan-t5-base",
|
| 26 |
model_kwargs={"temperature": 0, "max_length": 512},
|
| 27 |
huggingfacehub_api_token=hf_api_key
|
| 28 |
)
|
| 29 |
|
| 30 |
-
#
|
|
|
|
| 8 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
|
| 9 |
from reportlab.lib.styles import getSampleStyleSheet
|
| 10 |
from reportlab.lib import colors
|
| 11 |
+
from langchain_community.vectorstores import FAISS # Updated import for langchain-community
|
| 12 |
from langchain.embeddings import HuggingFaceEmbeddings
|
| 13 |
from langchain.document_loaders import DataFrameLoader
|
| 14 |
from langchain.chains import RetrievalQA
|
| 15 |
from langchain.llms import HuggingFaceHub
|
| 16 |
+
import os
|
| 17 |
|
| 18 |
+
# Retrieve Hugging Face API token from environment
|
| 19 |
hf_api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 20 |
if not hf_api_key:
|
| 21 |
st.error("Hugging Face API key is not set. Please configure it in the secret settings.")
|
| 22 |
|
| 23 |
+
# Initialize Hugging Face model
|
| 24 |
llm = HuggingFaceHub(
|
| 25 |
repo_id="google/flan-t5-base",
|
| 26 |
model_kwargs={"temperature": 0, "max_length": 512},
|
| 27 |
huggingfacehub_api_token=hf_api_key
|
| 28 |
)
|
| 29 |
|
| 30 |
+
# Rest of your app code...
|