Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import streamlit as st
|
3 |
from dotenv import load_dotenv
|
@@ -41,7 +59,7 @@ def get_vectorstore(text_chunks):
|
|
41 |
|
42 |
def get_conversation_chain(vectorstore):
|
43 |
# Fetch the HuggingFace API token from environment variable
|
44 |
-
api_token = os.getenv("HUGGINGFACE_API_TOKEN
|
45 |
if not api_token:
|
46 |
st.error("HuggingFace API token not found. Please ensure it is set in the environment variables.")
|
47 |
return None
|
|
|
1 |
+
import subprocess
|
2 |
+
import sys
|
3 |
+
|
4 |
+
# Function to install a package
|
5 |
+
def install_package(package):
|
6 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
7 |
+
|
8 |
+
# Install required packages if they are not already installed
|
9 |
+
required_packages = [
|
10 |
+
"PyPDF2", "streamlit", "langchain", "faiss-cpu",
|
11 |
+
"sentence-transformers", "python-dotenv"
|
12 |
+
]
|
13 |
+
for package in required_packages:
|
14 |
+
try:
|
15 |
+
__import__(package)
|
16 |
+
except ImportError:
|
17 |
+
install_package(package)
|
18 |
+
|
19 |
import os
|
20 |
import streamlit as st
|
21 |
from dotenv import load_dotenv
|
|
|
59 |
|
60 |
def get_conversation_chain(vectorstore):
|
61 |
# Fetch the HuggingFace API token from environment variable
|
62 |
+
api_token = os.getenv("HUGGINGFACE_API_TOKEN")
|
63 |
if not api_token:
|
64 |
st.error("HuggingFace API token not found. Please ensure it is set in the environment variables.")
|
65 |
return None
|