MOHITH2001 commited on
Commit
ea172ab
·
verified ·
1 Parent(s): 28c7afa

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -6
src/streamlit_app.py CHANGED
@@ -17,10 +17,6 @@ import subprocess
17
  # Temporary installation command
18
  subprocess.check_call([sys.executable, "-m", "pip", "install", "langchain", "langchain-community", "langchain-google-genai", "faiss-cpu", "pypdf"])
19
 
20
- load_dotenv(override=True)
21
-
22
- google_api_key=os.getenv("GOOGLE_API_KEY")
23
-
24
  st.set_page_config(page_title="RAG Document Chat",layout="wide")
25
 
26
  st.title("Text only Pdf Assisstant")
@@ -32,10 +28,17 @@ upload_file=st.sidebar.file_uploader("Upload the file",type="pdf")
32
  def load_embeddings():
33
  return HuggingFaceEmbeddings(model_name="all-MiniLm-L6-v2")
34
 
 
 
 
35
  def load_llm():
36
- return ChatGoogleGenerativeAI(model="gemini-2.5-flash",temperature=0.1)
 
 
 
 
37
 
38
- llm=load_llm()
39
  embeddings=load_embeddings()
40
 
41
  if upload_file:
 
17
  # Temporary installation command
18
  subprocess.check_call([sys.executable, "-m", "pip", "install", "langchain", "langchain-community", "langchain-google-genai", "faiss-cpu", "pypdf"])
19
 
 
 
 
 
20
  st.set_page_config(page_title="RAG Document Chat",layout="wide")
21
 
22
  st.title("Text only Pdf Assisstant")
 
28
  def load_embeddings():
29
  return HuggingFaceEmbeddings(model_name="all-MiniLm-L6-v2")
30
 
31
+ gemini_api_key = st.secrets["GOOGLE_API_KEY"]
32
+
33
+ @st.cache_resource
34
  def load_llm():
35
+ return ChatGoogleGenerativeAI(
36
+ model="gemini-1.5-flash",
37
+ temperature=0,
38
+ google_api_key=gemini_api_key # Pass the key here
39
+ )
40
 
41
+ llm = load_llm()
42
  embeddings=load_embeddings()
43
 
44
  if upload_file: