AzizWazir commited on
Commit
7ccfab9
·
verified ·
1 Parent(s): 79465a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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 langchain.vectorstores import FAISS
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 # For accessing environment variables
17
 
18
- # Retrieve the Hugging Face API token from environment variables
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 with the API key
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
- # (Remaining code is unchanged)
 
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...