Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files5 unmodified lines678991011124 unmodified lines1718192021222324252627285 unmodified lines3435363738394041424344454647484950515223 unmodified lines76777879806381828384858687888931 unmodified lines1211221231021031041241251261271281291301315 unmodified linesimport numpy as npfrom groq import Client
# Set background image and text color# 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 lines background-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 lines padding: 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 it try: index = faiss.read_index(vectorstore_path) 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 one index = faiss.IndexFlatL2(embedder.get_sentence_embedding_dimension())
# Function to load text from PDF31 unmodified lines index.add(np.array(embeddings)) # Save the updated FAISS index faiss.write_index(index, vectorstore_path) st.success("Document processed and vector store updated!") try: 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