Mpavan45 commited on
Commit
4116d1b
·
verified ·
1 Parent(s): acba3c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -23
app.py CHANGED
@@ -34,31 +34,11 @@ with st.container():
34
  # Safe way to access secrets
35
  GOOGLE_API_KEY = "AIzaSyBm0GOvYox4OyRG1WFOK7FT5fnNCHfubns"
36
 
 
 
 
37
 
38
- # Initialize Chroma DB
39
- @st.cache_resource
40
- def initialize_vectorstore(api_key):
41
- embedding = GoogleGenerativeAIEmbeddings(model="models/embedding-001", google_api_key=api_key)
42
- zip_path = "src/chroma_db1.zip"
43
- extract_dir = "src/chroma_db2"
44
- if os.path.exists(zip_path):
45
- try:
46
- with zipfile.ZipFile(zip_path, 'r') as zip_ref:
47
- zip_ref.extractall(extract_dir)
48
- vectorstore = Chroma(persist_directory=extract_dir, embedding_function=embedding)
49
- if vectorstore._collection.count() > 0:
50
- return vectorstore
51
- else:
52
- st.error("Chroma DB is empty after extraction.")
53
- except Exception as e:
54
- st.error(f"Failed to load Chroma DB: {str(e)}")
55
- else:
56
- st.error(f"`chroma_db1.zip` not found at {zip_path}")
57
- return None
58
 
59
- retriever = None
60
- vectorstore = None
61
- llm, parser = None, None
62
 
63
  if GOOGLE_API_KEY:
64
  vectorstore = initialize_vectorstore(GOOGLE_API_KEY)
 
34
  # Safe way to access secrets
35
  GOOGLE_API_KEY = "AIzaSyBm0GOvYox4OyRG1WFOK7FT5fnNCHfubns"
36
 
37
+ embedding = GoogleGenerativeAIEmbeddings(model="models/embedding-001", google_api_key=api_key)
38
+ vectorstore = Chroma(persist_directory=chroma_db, embedding_function=embedding)
39
+
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
 
 
 
42
 
43
  if GOOGLE_API_KEY:
44
  vectorstore = initialize_vectorstore(GOOGLE_API_KEY)