Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files5 unmodified lines67891011124 unmodified lines1718192021222324255 unmodified lines31323334353623 unmodified lines606162636465666731 unmodified lines991001011021031041051061075 unmodified linesimport numpy as npfrom groq import Client# Set background image and text colorbackground_image_url = "https://jamesclear.com/wp-content/uploads/2020/11/atomic-habits_gallery_hi-res_01.jpg"st.markdown(f"""4 unmodified linesbackground-position: center center;background-repeat: no-repeat;}}h1, h2, h3, h4, h5, h6, p {{color: black; /* Set text color to black */}}.footer {{position: fixed;bottom: 0;5 unmodified linespadding: 10px 0;font-size: 14px;}}</style>""",unsafe_allow_html=True23 unmodified lines# Load or create FAISS indexif os.path.exists(vectorstore_path):index = faiss.read_index(vectorstore_path)else:index = faiss.IndexFlatL2(embedder.get_sentence_embedding_dimension())# Function to load text from PDF31 unmodified linesindex.add(np.array(embeddings))# Save the updated FAISS indexfaiss.write_index(index, vectorstore_path)st.success("Document processed and vector store updated!")# User interface for Streamlitst.title("Atomic Habits RAG Application")5 unmodified lines67891011124 unmodified lines1718192021222324252627285 unmodified lines3435363738394041424344454647484950515223 unmodified lines767778798081828384858687888931 unmodified lines1211221231241251261271281291301315 unmodified linesimport numpy as npfrom groq import Client# Set background image and customize colorsbackground_image_url = "https://jamesclear.com/wp-content/uploads/2020/11/atomic-habits_gallery_hi-res_01.jpg"st.markdown(f"""4 unmodified linesbackground-position: center center;background-repeat: no-repeat;}}/* Set title and footer text color to black */h1, h2, h3, h4, h5, h6, p {{color: black; /* Set text color to black */}}/* Set footer styling */.footer {{position: fixed;bottom: 0;5 unmodified linespadding: 10px 0;font-size: 14px;}}/* Set processing button color to green */.stButton button {{background-color: green;color: white;}}/* Set query input block background color to white */.stTextInput input {{background-color: white;color: black;}}</style>""",unsafe_allow_html=True23 unmodified lines# Load or create FAISS indexif os.path.exists(vectorstore_path):# If the index file exists, read ittry:index = faiss.read_index(vectorstore_path)except Exception as e:st.error(f"Error reading the FAISS index: {e}")index = faiss.IndexFlatL2(embedder.get_sentence_embedding_dimension())else:# If the index file doesn't exist, create a new oneindex = faiss.IndexFlatL2(embedder.get_sentence_embedding_dimension())# Function to load text from PDF31 unmodified linesindex.add(np.array(embeddings))# Save the updated FAISS indextry:faiss.write_index(index, vectorstore_path)st.success("Document processed and vector store updated!")except Exception as e:st.error(f"Error saving the FAISS index: {e}")# User interface for Streamlitst.title("Atomic Habits RAG Application")
app.py+29-5