Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files6 unmodified lines78910101112134 unmodified lines181920212223242526272829303132333435363738392122234 unmodified lines2829303132333435363738394041424344454692 unmodified lines13914014114814915015114214314414517 unmodified lines1631641651751761771781791801811661671681691701711721731741751761771781791831841851861871881891801811821831841851861871881891931946 unmodified linesfrom 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"background_image_url = "https://www.shutterstock.com/image-vector/artificial-intelligence-circuit-electric-line-600nw-2465096659.jpg"st.markdown( f""" <style>4 unmodified lines background-repeat: no-repeat; }} /* Custom Top Bar */ .top-bar {{ position: fixed; top: 0; left: 0; right: 0; background-color: rgba(0, 0, 0, 0.6); color: white; text-align: center; padding: 15px 0; font-size: 24px; z-index: 10; }}
/* Content under the top bar */ .main-content {{ margin-top: 80px; /* To create space for the top bar */ }} /* Ensure title is black */ h1 {{ color: black !important; /* Force title color to black */4 unmodified lines color: black; /* Set text color to black */ }} /* Set footer styling */ .footer {{ position: fixed; bottom: 0; left: 0; right: 0; background-color: rgba(0, 0, 0, 0.6); color: white; text-align: center; padding: 10px 0; font-size: 14px; }} /* Set processing button color to green */ .stButton button {{ background-color: green;92 unmodified lines st.error(f"Error saving the FAISS index: {e}")
# User interface for Streamlitst.markdown('<div class="top-bar">Atomic Habits RAG Application</div>', unsafe_allow_html=True)
# Content under the top barst.markdown('<div class="main-content">', unsafe_allow_html=True)st.title("Atomic Habits RAG Application")
# Button to trigger document processingif st.button("Process PDF"):17 unmodified lines if indices.size == 0 or np.any(indices[0] == -1): st.error("No relevant results found in the index.") else: # Retrieve the most relevant chunks based on the indices retrieved_chunks = [chunks[idx] for idx in indices[0]] # Display the retrieved chunks st.subheader("Retrieved Chunks") for chunk in retrieved_chunks: st.write(chunk) # Ensure indices are within the bounds of the chunks list valid_indices = [idx for idx in indices[0] if idx < len(chunks)] if not valid_indices: st.error("No valid indices found for the retrieved chunks.") else: # Retrieve the most relevant chunks based on the valid indices retrieved_chunks = [chunks[idx] for idx in valid_indices] # Display the retrieved chunks st.subheader("Retrieved Chunks") for chunk in retrieved_chunks: st.write(chunk) # Combine the retrieved chunks with the query and generate a response using Groq combined_input = " ".join(retrieved_chunks) + user_query response = groq_client.generate(model="llama3-8b-8192", prompt=combined_input, max_tokens=200) # Display the generated response st.subheader("Generated Response") st.write(response["text"]) # Combine the retrieved chunks with the query and generate a response using Groq combined_input = " ".join(retrieved_chunks) + user_query response = groq_client.generate(model="llama3-8b-8192", prompt=combined_input, max_tokens=200) # Display the generated response st.subheader("Generated Response") st.write(response["text"])
# Footerst.markdown("<div class='footer'>Created by Shamil Shahbaz</div>", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True) # End the main content divapp.py+35-40