{"id":16780616,"url":"https://github.com/edwinjosechittilappilly/ragstackdemo","last_synced_at":"2026-05-18T22:04:50.920Z","repository":{"id":234088422,"uuid":"788263623","full_name":"edwinjosechittilappilly/RAGStackDemo","owner":"edwinjosechittilappilly","description":"Philosopher Quote Retriever with Langchain","archived":false,"fork":false,"pushed_at":"2024-04-18T08:11:37.000Z","size":3907,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T06:45:19.187Z","etag":null,"topics":["astradb","datastax","rag","ragstack"],"latest_commit_sha":null,"homepage":"https://ragstackdemo.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edwinjosechittilappilly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-18T04:45:00.000Z","updated_at":"2024-11-09T23:06:38.000Z","dependencies_parsed_at":"2024-12-03T14:26:50.166Z","dependency_job_id":"05e5b73b-b75f-4adc-9bac-124b85c74ef1","html_url":"https://github.com/edwinjosechittilappilly/RAGStackDemo","commit_stats":null,"previous_names":["edwinjosechittilappilly/ragstackdemo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinjosechittilappilly%2FRAGStackDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinjosechittilappilly%2FRAGStackDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinjosechittilappilly%2FRAGStackDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinjosechittilappilly%2FRAGStackDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwinjosechittilappilly","download_url":"https://codeload.github.com/edwinjosechittilappilly/RAGStackDemo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243925990,"owners_count":20369914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astradb","datastax","rag","ragstack"],"created_at":"2024-10-13T07:35:32.708Z","updated_at":"2026-05-18T22:04:50.825Z","avatar_url":"https://github.com/edwinjosechittilappilly.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAGStackDemo\nStreamlit App URL: https://ragstackdemo.streamlit.app/\n\n# Philosopher Quote Retriever with Langchain\n\nThis repository contains code for a retrieval system that utilizes Langchain to retrieve quotes from a philosopher based on user queries. The system leverages the following components:\n\n* **Langchain:** A framework for building conversational AI applications.\n* **Google Generative AI:** A large language model for text generation and retrieval.\n* **Astra DB Vector Store:** A database for storing and searching vector representations of text.\n## Architecture Overview\n\n\u003cimg src=\"./arch/RagstackDemo.gif\"\u003e \n\n### Project Structure:\n\n* `src/`: Contains the core Python code for the chatbot functionality.\n    * `rag.py`: Defines the RAG logic for retrieving quotes based on user queries.\n    * `chat.py`: Implements the chat interaction logic using Streamlit components.\n    * `app.py`: The main Streamlit application file that ties everything together.\n\n### Code:\n\n**rag.py:**\n\nThis file handles the core retrieval functionality using Langchain:\n\n* It defines two retrieval chains:\n    * `rag_chain_with_source_multi`: Uses a multi-query retriever for retrieving quotes, leveraging paraphrasing to improve retrieval effectiveness.\n    * `rag_chain_with_source_basic`: Falls back to a vector score retriever if the multi-query retriever fails.\n* It utilizes an LLM (large language model) to generate variations of the user's question for better retrieval.\n\n* **Environment Variables:**\n  * `GOOGLE_API_KEY`: API key for accessing Google Generative AI.\n  * `ASTRA_DB_API_ENDPOINT`: Endpoint for Astra DB.\n  * `ASTRA_DB_APPLICATION_TOKEN`: Authentication token for Astra DB.\n  * `ASTRA_DB_KEYSPACE_Philo`: Keyspace name in Astra DB where quotes are stored.\n* **LLM (Large Language Model):** An instance of `GoogleGenerativeAI` is created for text generation and retrieval tasks.\n* **Vector Embeddings:** A `GoogleGenerativeAIEmbeddings` instance is used to generate vector representations of text for efficient retrieval.\n* **Astra DB Vector Store:** A connection to the Astra DB vector store is established using `AstraDBVectorStore`.\n* **Retrievers:**\n  * `retriever_vector_score`: Retrieves quotes based on vector similarity using the Astra DB vector store.\n  * `retriever_self_query`: Uses the LLM to generate multiple query variations based on the user's question to improve retrieval effectiveness.\n* **Output Parser:** `LineListOutputParser` parses the LLM response and extracts a list of generated queries.\n* **Prompts:**\n  * `QUERY_PROMPT`: LLM prompt template for generating multiple query variations.\n* **LLM Chain:** Combines the LLM with the `QUERY_PROMPT` and `LineListOutputParser` for query variation generation.\n* **Multi-Query Retriever:** `retriever_multi_query` combines the vector score retriever and the LLM chain for retrieving quotes using both similarity search and paraphrased queries.\n* **RAG Chain:** Defines the core conversation flow:\n  * Retrieves context (quotes) from previous interactions.\n  * Processes the user's question along with the retrieved context.\n  * Uses the LLM to generate a response based on the context and question.\n  * Formats the response for the user.\n* **Runnable Chains:**\n  * `rag_chain_with_source_multi`: Uses the multi-query retriever for retrieving quotes.\n  * `rag_chain_with_source_basic`: Uses the vector score retriever for retrieving quotes (fallback if multi-query retriever fails).\n\n\n**chat.py:**\n\nThis file implements the interactive chat interface using Streamlit:\n\n* It defines the `chatHere` function to handle user input and generate assistant responses.\n* It displays chat history, accepts user input, and displays the assistant's response.\n* It utilizes the `rag_chain_with_source_multi` and `rag_chain_with_source_basic` functions from `rag.py` for retrieving responses.\n* It stores conversation history in the Streamlit session state.\n\n**app.py:**\n\nThis file is the main entry point for the Streamlit application:\n\n* It sets the app title and user information section.\n* It calls the `chatHere` function from `chat.py` to handle the chat interaction.\n\n**Running the Project:**\n\n1. Install dependencies: `pip install -r requirements.txt`\n2. Set the required environment variables (refer to the code for details).\n3. Run the script: `streamlit run src/app.py`\n4. The script will open streamlit app and asksto prompt you for a question (e.g., \"give a quote by plato\").\n5. It will then retrieve relevant quotes and provide a response based on the retrieved context.\n\n**Note:** This is a basic example and can be extended to include additional features such as:\n\n* Support for retrieving quotes by multiple philosophers.\n* Filtering quotes based on tags or categories.\n* Summarization of retrieved quotes.\n* Integration with Evaluation API for feedback and improvement.\n* Integration with much better retreival Stratergies like Colbert, and RAPTOR.\n\n### Screenshots:\nhttps://ragstackdemo.streamlit.app/\n\n\u003cimg src=\"./arch/screenshot.png\"\u003e \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwinjosechittilappilly%2Fragstackdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwinjosechittilappilly%2Fragstackdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwinjosechittilappilly%2Fragstackdemo/lists"}