Update app_streamlit.py
Browse files- app_streamlit.py +16 -0
app_streamlit.py
CHANGED
@@ -8,6 +8,7 @@ from langchain.vectorstores import Chroma
|
|
8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
from langchain_groq import ChatGroq
|
10 |
from langchain.chains import RetrievalQA
|
|
|
11 |
|
12 |
# Load the .env file (if using it)
|
13 |
load_dotenv()
|
@@ -16,6 +17,21 @@ groq_api_key = os.getenv("GROQ_API_KEY")
|
|
16 |
# Load embeddings, model, and vector store
|
17 |
@st.cache_resource # Singleton, prevent multiple initializations
|
18 |
def init_chain():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
model_kwargs = {'trust_remote_code': True}
|
20 |
embedding = HuggingFaceEmbeddings(model_name='nomic-ai/nomic-embed-text-v1.5', model_kwargs=model_kwargs)
|
21 |
llm = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192", temperature=0.2)
|
|
|
8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
from langchain_groq import ChatGroq
|
10 |
from langchain.chains import RetrievalQA
|
11 |
+
import zipfile
|
12 |
|
13 |
# Load the .env file (if using it)
|
14 |
load_dotenv()
|
|
|
17 |
# Load embeddings, model, and vector store
|
18 |
@st.cache_resource # Singleton, prevent multiple initializations
|
19 |
def init_chain():
|
20 |
+
|
21 |
+
# Specify the path to the .zip file
|
22 |
+
zip_file_path = "cspc_db.zip"
|
23 |
+
|
24 |
+
# Specify the directory where you want to extract the files
|
25 |
+
extract_to_path = "cspc_db"
|
26 |
+
|
27 |
+
# Check if the destination directory exists, and if not, create it
|
28 |
+
if not os.path.exists(extract_to_path):
|
29 |
+
os.makedirs(extract_to_path)
|
30 |
+
|
31 |
+
# Unzip the file
|
32 |
+
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
33 |
+
zip_ref.extractall(extract_to_path)
|
34 |
+
|
35 |
model_kwargs = {'trust_remote_code': True}
|
36 |
embedding = HuggingFaceEmbeddings(model_name='nomic-ai/nomic-embed-text-v1.5', model_kwargs=model_kwargs)
|
37 |
llm = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192", temperature=0.2)
|