Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files6 unmodified lines789101112134 unmodified lines181920212223242526272829303132333435363738394041424 unmodified lines47484950515292 unmodified lines14514614714814915015115215315417 unmodified lines1721731741751761771781791801811821831841851861871881891901911921931946 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"st.markdown(f"""<style>4 unmodified linesbackground-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 linescolor: black; /* Set text color to black */}}/* Set processing button color to green */.stButton button {{background-color: green;92 unmodified linesst.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)# Button to trigger document processingif st.button("Process PDF"):17 unmodified linesif 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 indicesretrieved_chunks = [chunks[idx] for idx in indices[0]]# Display the retrieved chunksst.subheader("Retrieved Chunks")for chunk in retrieved_chunks:st.write(chunk)# Combine the retrieved chunks with the query and generate a response using Groqcombined_input = " ".join(retrieved_chunks) + user_queryresponse = groq_client.generate(model="llama3-8b-8192", prompt=combined_input, max_tokens=200)# Display the generated responsest.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 div6 unmodified lines789101112134 unmodified lines1819202122234 unmodified lines2829303132333435363738394041424344454692 unmodified lines13914014114214314414517 unmodified lines1631641651661671681691701711721731741751761771781791801811821831841851861871881896 unmodified linesfrom groq import Client# Set background image and customize colorsbackground_image_url = "https://www.shutterstock.com/image-vector/artificial-intelligence-circuit-electric-line-600nw-2465096659.jpg"st.markdown(f"""<style>4 unmodified linesbackground-repeat: no-repeat;}}/* Ensure title is black */h1 {{color: black !important; /* Force title color to black */4 unmodified linescolor: 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 linesst.error(f"Error saving the FAISS index: {e}")# User interface for Streamlitst.title("Atomic Habits RAG Application")# Button to trigger document processingif st.button("Process PDF"):17 unmodified linesif indices.size == 0 or np.any(indices[0] == -1):st.error("No relevant results found in the index.")else:# Ensure indices are within the bounds of the chunks listvalid_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 indicesretrieved_chunks = [chunks[idx] for idx in valid_indices]# Display the retrieved chunksst.subheader("Retrieved Chunks")for chunk in retrieved_chunks:st.write(chunk)# Combine the retrieved chunks with the query and generate a response using Groqcombined_input = " ".join(retrieved_chunks) + user_queryresponse = groq_client.generate(model="llama3-8b-8192", prompt=combined_input, max_tokens=200)# Display the generated responsest.subheader("Generated Response")st.write(response["text"])# Footerst.markdown("<div class='footer'>Created by Shamil Shahbaz</div>", unsafe_allow_html=True)
app.py+35-40