{"id":18464026,"url":"https://github.com/labrijisaad/llm-rag","last_synced_at":"2026-02-26T07:03:12.305Z","repository":{"id":230892011,"uuid":"780385312","full_name":"labrijisaad/LLM-RAG","owner":"labrijisaad","description":"A Streamlit app leveraging a RAG LLM with FAISS to offer answers from uploaded files.","archived":false,"fork":false,"pushed_at":"2024-04-13T14:25:38.000Z","size":1370,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T04:29:15.070Z","etag":null,"topics":["chatgpt","cicd","embedding-vectors","faiss","llm","machine-learning","mlops","openai","rag","rag-llm","streamlit","streamlit-webapp"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/labrijisaad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-04-01T11:16:10.000Z","updated_at":"2024-04-15T21:41:11.191Z","dependencies_parsed_at":"2024-04-13T15:45:28.260Z","dependency_job_id":null,"html_url":"https://github.com/labrijisaad/LLM-RAG","commit_stats":null,"previous_names":["labrijisaad/llm-rag"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/labrijisaad/LLM-RAG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrijisaad%2FLLM-RAG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrijisaad%2FLLM-RAG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrijisaad%2FLLM-RAG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrijisaad%2FLLM-RAG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labrijisaad","download_url":"https://codeload.github.com/labrijisaad/LLM-RAG/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrijisaad%2FLLM-RAG/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29851221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"online","status_checked_at":"2026-02-26T02:00:06.774Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chatgpt","cicd","embedding-vectors","faiss","llm","machine-learning","mlops","openai","rag","rag-llm","streamlit","streamlit-webapp"],"created_at":"2024-11-06T09:08:38.041Z","updated_at":"2026-02-26T07:03:12.270Z","avatar_url":"https://github.com/labrijisaad.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `LLM RAG` - Streamlit RAG Language Model App 🤖\n\n## 🌟 Overview \nThis Streamlit app leverages Retrieval-Augmented Generation (RAG) by using OpenAI's Large Language Model (LLM) in conjunction with FAISS, a vector database. The app allows users to upload markdown files 📂, ask questions related to the content of these files ❓, and receive AI-generated answers based on the uploaded content 📚.\n\n## ❓ How It Works\nThe LLM RAG Streamlit app is structured into several key areas, each serving a specific function within the application:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/labrijisaad/LLM-RAG/assets/74627083/61518120-e3a0-4e76-84ea-4fb11bd82e4a\" width=\"60%\" /\u003e\n\u003c/p\u003e\n\n- **Setup Knowledge Base** 📂: Upload markdown documents to establish the knowledge base.\n- **Explore Knowledge Base** 🔍: Browse and manage the uploaded documents.\n- **RAG Query** 💡: Pose questions to receive answers referencing the knowledge base and the model's knowledge.\n\nAdditionally, the app offers advanced settings for customization based on user needs:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/labrijisaad/LLM-RAG/assets/74627083/8f878a40-f268-4ba9-ae0f-75ca2391357d\" width=\"30%\" /\u003e\n\u003c/p\u003e\n\n- **OpenAI Embedding Model Settings**: Select the embedding model for document vectorization.\n- **OpenAI LLM Settings**: Choose the OpenAI language model variant for generating answers.\n- **LLM Temperature**: Adjust the creativity of the model’s responses.\n- **Max Completion Tokens**: Define the maximum length of the generated response.\n- **Drop All Documents in Knowledge Base**: Clear the database by typing a confirmatory command.\n\n## 🛠️ System Architecture\nThe following diagram illustrates the flow of data through the system:\n\n```mermaid\ngraph TD\n    A[Markdown Documents] --\u003e|Data Cleaning \u0026\u003cbr\u003eSplitting in Chunks| B[Cleaned Text]\n    B --\u003e|OpenAI Model\u003cbr\u003eEmbedding| C[Document Embeddings]\n    C --\u003e|Store| D[(Vectorstore)]\n    D --\u003e|Similarity Search| E[Relevant Documents]\n \n    F[User Question] --\u003e|OpenAI Model\u003cbr\u003eEmbedding| G[Query Embedding]\n    G --\u003e|Fetch| D\n \n    F --\u003e J[Contextualized Prompt]\n    E --\u003e J\n    J --\u003e|OpenAI LLM Model| L[Answer]\n \n    subgraph Data Preparation\n        A\n        B\n    end\n \n    subgraph Vectorization\n        C\n        G\n    end\n \n    subgraph Relevant Documents Retrieval\n        D\n        E\n    end\n \n    subgraph LLM Querying\n        J\n        L\n    end\n \n    %% Styles\n    style A fill:#7f7f7f,stroke:#fff,stroke-width:2px\n    style B fill:#8fa1b3,stroke:#fff,stroke-width:2px\n    style C fill:#8fa1b3,stroke:#fff,stroke-width:2px\n    style D fill:#8fa1b3,stroke:#fff,stroke-width:2px\n    style E fill:#8fa1b3,stroke:#fff,stroke-width:2px\n    style F fill:#7f7f7f,stroke:#fff,stroke-width:2px\n    style G fill:#8fa1b3,stroke:#fff,stroke-width:2px\n    style J fill:#e07b53,stroke:#fff,stroke-width:2px\n    style L fill:#e07b53,stroke:#fff,stroke-width:2px\n```\n\n## Project Structure 🏗️\nThe project's main directories are laid out as follows:\n\n```\nLLM-RAG/\n├── .github/workflows/          # CI/CD pipeline definitions\n├── configs/                    # Configuration files for the model (model names, pricing..)\n├── data/                       # Data and indices used by the app (FAISS Knowledge Base)\n├── docker/                     # Docker related files \n├── notebooks/                  # Jupyter notebooks for experiments\n├── secrets/                    # API keys and other secrets (excluded from version control)\n├── src/                        # Source code for the LLM RAG logic\n├── streamlit_app/              # Streamlit app files for the Web Interface\n├── tests/                      # Test cases for the application\n├── .dockerignore               # Specifies ignored files in Docker builds\n├── .gitignore                  # Specifies untracked files ignored by git\n├── Dockerfile                  # Dockerfile for building the Docker image\n├── Makefile                    # Make commands for building and running the app 🧑‍💻\n├── README.md                   # Documentation and instructions\n├── requirements.txt            # Python dependencies for the project\n└── (additional project files and scripts)\n```\n\n## 🚀 Getting Started\n\nTo begin using the LLM RAG app, follow these simple steps:\n\n1. **Clone the Repository:**\n   ```\n   git clone https://github.com/labrijisaad/LLM-RAG.git\n   ```\n\n2. **Create the Environment:**\n   Set up your virtual environment using either venv or conda:\n   ```\n   # Using venv\n   python -m venv env_llm_rag\n   source env_llm_rag/bin/activate\n   \n   # Using conda\n   conda create --name env_llm_rag\n   conda activate env_llm_rag\n   ```\n\n3. **Install Dependencies:**\n   Install the required dependencies by\n\n running:\n   ```\n   pip install -r requirements.txt\n   ```\n\n4. **Set Up OpenAI API:**\n   Rename the example credentials file to `secrets/credentials.yml` and replace the placeholder key ('sk-xxx') with your actual OpenAI API key. You can obtain your API key by following the instructions provided in the [OpenAI documentation](https://platform.openai.com/docs/quickstart?context=python).\n   ```\n   rename secrets/credentials-example.yml secrets/credentials.yml\n   ```\n\n5. **Run the Streamlit App:**\n   Launch the Streamlit app using either the provided Makefile command or directly via the Streamlit CLI:\n   ```\n   # Using Makefile\n   make stream\n   \n   # Or directly\n   streamlit run streamlit_app/main.py\n   ```\n## 🐳 Docker Version\n\nThe application is available as a Docker container and can be easily set up and run with a few commands. If you want to run the application using the Docker image from the public registry, ensure that you have a `secrets` directory with the necessary API keys as specified in the `secrets/credentials.yml`.\n\nTo pull and run the Docker container:\n\n1. **Pull the Docker Image:**\n   You can pull the image directly from **Google Artifact Registry** using the following command:\n   ```shell\n   docker pull europe-west1-docker.pkg.dev/llm-rag-application/llm-rag/llm_rag_app:latest\n   ```\n\n2. **Run the Docker Container:**\n   After pulling the image, you can run it with:\n   ```shell\n   docker run -p 8501:8501 -v $(pwd)/secrets:/app/secrets europe-west1-docker.pkg.dev/llm-rag-application/llm-rag/llm_rag_app:latest\n   ```\n   This command will start the container and mount your **`secrets`** directory for the application to use.\n\nIf you prefer to use the **Makefile**, the equivalent commands are provided for convenience:\n\n```shell\n# To pull the Docker image\nmake docker-pull\n\n# To run the pulled Docker image\nmake docker-run-pulled\n```\n\nThe Streamlit app will be available at **`http://localhost:8501`** once the container is running.\n\n\n## 🌐 Connect with me\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.linkedin.com/in/labrijisaad/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/LinkedIn-%230077B5.svg?\u0026style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\" alt=\"LinkedIn\" style=\"margin-bottom: 5px;\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/labrijisaad\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\" alt=\"GitHub\" style=\"margin-bottom: 5px;\"/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabrijisaad%2Fllm-rag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabrijisaad%2Fllm-rag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabrijisaad%2Fllm-rag/lists"}