Spaces:
Paused
Paused
change doc used for searching
Browse files10 unmodified lines1112131415161718192021222316 unmodified lines404142434445464748495051525354554 unmodified lines606162636465666768697071727374759 unmodified lines858687888990918 unmodified lines10010110210310410510610710810911011111211311411511611711810 unmodified linesif "search_results" not in st.session_state:st.session_state["search_results"] = []client = Colivara(base_url="https://api.colivara.com", api_key=API_KEY)# Add badges at the top of the pagest.markdown("""<div style="display: flex; gap: 10px; margin-bottom: 20px;"><a href="https://discord.gg/DtGRxWuj8y" target="_blank"><img src="https://dcbadge.limes.pink/api/server/https://discord.gg/DtGRxWuj8y" alt="Discord"></a><a href="https://www.colivara.com" target="_blank"><img src="https://img.shields.io/badge/Website-0078D7?style=for-the-badge&logo=internetexplorer&logoColor=white" alt="Website">16 unmodified linesst.markdown("""### Welcome to the Colivara Search DemoThis demo allows you to search through a sample NVIDIA quarterly report (Form 10-Q).- Enter a search query in the input box below.- Retrieve the most relevant pages from the document.**Example Queries:**```1. What were Nvidia's revenues for the most recent quarter?2. What are the main factors that are driving Nvidia's growth?3. What are the risks and challenges that Nvidia is facing?```Try it out and see how the AI retrieves the information you need efficiently.4 unmodified linesst.markdown("""#### Document Overview:**Title:** NVIDIA Corporation Quarterly Report (Form 10-Q, October 27, 2024)**Type:** PDF**Pages:** 50+<a href="https://d18rn0p25nwr6d.cloudfront.net/CIK-0001045810/ed2a395c-5e9b-4411-8b4a-a718d192155a.pdf" target="_blank"><img src="https://img.shields.io/badge/View%20PDF-EF8D21?style=for-the-badge&logo=adobeacrobatreader&logoColor=white" alt="View PDF"></a>""",unsafe_allow_html=True,)# Search and retrieve documentsst.subheader("Search and Retrieve Documents")9 unmodified lineshelp="Select the number of top pages to retrieve.",)collection_name = "Demo-Final"if st.button("Search"):if not query:st.error("Please enter a search query to retrieve results.")8 unmodified linesst.error(f"Error during search: {str(e)}")# Display search resultsif "search_results" in st.session_state and st.session_state["search_results"]:st.write("### Search Results")cols = st.columns(2)for idx, result in enumerate(st.session_state["search_results"]):img_base64 = result.img_base64page_number = result.page_numberdocument_name = result.document_nameimg = Image.open(BytesIO(base64.b64decode(img_base64)))cols[idx % 2].image(img,caption=f"Document: {document_name}, Page: {page_number}",)st.success("Search completed successfully.")st.markdown("----")st.markdown("Developed by Abdulhaleem from TJM Labs.")10 unmodified lines1112131415161718192021222316 unmodified lines404142434445464748495051525354555657585960616263646566674 unmodified lines727374757677787980818283848586878889909 unmodified lines1001011021031041051068 unmodified lines11511611711811912012112212312412512612712812913013113213313413513613713813914014114210 unmodified linesif "search_results" not in st.session_state:st.session_state["search_results"] = []client = Colivara(api_key=API_KEY)# Add badges at the top of the pagest.markdown("""<div style="display: flex; gap: 10px; margin-bottom: 20px;"><a href="https://discord.gg/DtGRxWuj8y" target="_blank"><img src="https://img.shields.io/badge/Join%20Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white" alt="Discord"></a><a href="https://www.colivara.com" target="_blank"><img src="https://img.shields.io/badge/Website-0078D7?style=for-the-badge&logo=internetexplorer&logoColor=white" alt="Website">16 unmodified linesst.markdown("""### Welcome to the Colivara Search DemoThis demo allows you to search through the Competitive Programmer's Handbook by Antti Laaksonen.We included 12 chapters from the handbook in this demo to help you understand how Colivara works.**Chapters Covered:**`Introduction` `Time Complexity` `Sorting` `Data Structures` `Complete Search` `Greedy Algorithms` `Dynamic Programming` `Amortized Analysis` `Range Queries` `Bit Manipulation` `Basics of Graphs` `Graph Traversal`- Enter a search query in the input box below.- Retrieve the most relevant pages from the document.**Example Queries:**```1. What is set theory?2. How to analyze complexity using Big O notation?3. Explain Binary Search Algorithm and provide implementation of lower bound.4. How to use Stack, Queue and Deque?5. Explain generating permutations and subsets in Complete Search.6. What makes an algorithm greedy?7. How to solve the coin change problem using Dynamic Programming?8. What is amortized analysis?9. How to implement prefix sum array?10. Explain basic bitwise operations.11. Show graph representation using matrix and adjacency list.12. How to implement DFS and BFS traversal?```Try it out and see how the AI retrieves the information you need efficiently.4 unmodified linesst.markdown("""#### Document Overview:**Title:** Competitive Programmer's Handbook**Author:** Antti Laaksonen**Type:** PDF**Included Pages:** 100+**Included Chapters Count:** 12**Full Book Chapters Count:** 30<a href="https://cses.fi/book/book.pdf" target="_blank"><img src="https://img.shields.io/badge/View%20PDF-EF8D21?style=for-the-badge&logo=adobeacrobatreader&logoColor=white" alt="View PDF"></a>""",unsafe_allow_html=True,)# Search and retrieve documentsst.subheader("Search and Retrieve Documents")9 unmodified lineshelp="Select the number of top pages to retrieve.",)collection_name = "Algorithm"if st.button("Search"):if not query:st.error("Please enter a search query to retrieve results.")8 unmodified linesst.error(f"Error during search: {str(e)}")# Display search resultsif "search_results" in st.session_state and st.session_state["search_results"]:st.write("### Search Results")# Remove the columns and display images one by onefor idx, result in enumerate(st.session_state["search_results"]):img_base64 = result.img_base64page_number = result.page_numberdocument_name = result.document_nameimg = Image.open(BytesIO(base64.b64decode(img_base64)))# Create a container for each resultwith st.container():# Display the image with increased widthst.image(img,caption=f"Document: {document_name}, Page: {page_number}",use_container_width=True, # This makes the image use full column width)# Add some spacing between imagesst.markdown("---")st.success("Search completed successfully.")st.markdown("----")st.markdown("Developed by Abdulhaleem @ TJM Labs.")
app.py+41-17