{"id":29313013,"url":"https://github.com/hardikpatelse/aichatbot","last_synced_at":"2026-04-16T10:34:48.141Z","repository":{"id":301378733,"uuid":"1007117968","full_name":"hardikpatelse/AIChatBot","owner":"hardikpatelse","description":"A full-stack AI chatbot using local (Ollama) \u0026 cloud (OpenRouter) LLMs. Built with .NET 9 API \u0026 Angular 20 UI. Easily run models like PHI-3, Mistral, Gemma, Llama3 locally or online.","archived":false,"fork":false,"pushed_at":"2025-07-06T13:41:21.000Z","size":230,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-06T14:35:03.540Z","etag":null,"topics":["ai-chatbot","angular","chatbot","dot-net","dot-net-9","dotnet","full-stack","llm","local-ai","ollama","ollama-api","openai-alternative","openrouter","openrouter-api","wsl","wsl-ubuntu"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardikpatelse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2025-06-23T13:43:45.000Z","updated_at":"2025-07-06T13:38:02.000Z","dependencies_parsed_at":"2025-06-26T15:44:33.537Z","dependency_job_id":null,"html_url":"https://github.com/hardikpatelse/AIChatBot","commit_stats":null,"previous_names":["hardikpatelse/aichatbot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hardikpatelse/AIChatBot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikpatelse%2FAIChatBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikpatelse%2FAIChatBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikpatelse%2FAIChatBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikpatelse%2FAIChatBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardikpatelse","download_url":"https://codeload.github.com/hardikpatelse/AIChatBot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikpatelse%2FAIChatBot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264049080,"owners_count":23549405,"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":["ai-chatbot","angular","chatbot","dot-net","dot-net-9","dotnet","full-stack","llm","local-ai","ollama","ollama-api","openai-alternative","openrouter","openrouter-api","wsl","wsl-ubuntu"],"created_at":"2025-07-07T09:13:57.238Z","updated_at":"2026-04-16T10:34:48.129Z","avatar_url":"https://github.com/hardikpatelse.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 AIChatBot\n\nAIChatBot is a local and online AI-powered chatbot built using open-source language models. This project supports both locally hosted models (via [Ollama](https://ollama.com)) and cloud-based models via [OpenRouter](https://openrouter.ai). It demonstrates the integration of AI with a .NET 8 API and Angular 20 frontend.\n\n## ✨ Latest Features\n\n### 🆕 RAG (Retrieval-Augmented Generation) Integration\nTransform your chatbot experience with **Knowledge-Based AI**! Upload your documents and get contextually-aware responses based on your own content.\n\n**Key Highlights:**\n- 📄 **Multi-format Document Support**: Upload `.txt`, `.md`, and `.pdf` files\n- 🔍 **Intelligent Document Search**: Advanced retrieval algorithms find relevant content\n- 💬 **Context-Aware Responses**: AI answers based on your uploaded documents\n- 📊 **Source Attribution**: See exactly which documents informed each response  \n- 🗂️ **Document Management**: Easy upload, view, and delete capabilities\n- 👤 **User-Specific Collections**: Each user maintains their own document library\n\nExperience AI that truly understands YOUR content!\n\n---\n\n## 🎬 Demo Video\n\nWatch the AIChatBot in action on YouTube:  \n📺 [AIChatBot Demo](https://youtu.be/ReTiWZABiD8)\n\n---\n\n\n## 🛠️ Prerequisites\n\nTo run this project locally, ensure the following:\n\n- Windows 10/11 with WSL support\n- Installed Ubuntu 20.04.6 LTS (via Microsoft Store)\n- [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download)\n- [Node.js (v20+)](https://nodejs.org/)\n- [Angular CLI](https://angular.io/cli) (`npm install -g @angular/cli`)\n- [Ollama](https://ollama.com/download) installed in Ubuntu for running local AI models\n- Optional: Account on [https://openrouter.ai](https://openrouter.ai)\n\n---\n\n## 🧱 Environment Setup (Local Models using Ollama)\n\n### 1. Install Ubuntu 20.04.6 LTS\n\n- Go to Microsoft Store → Search for **Ubuntu 20.04.6 LTS** → Install.\n- Open Ubuntu and create your UNIX user account.\n\n### 2. Install Ollama inside Ubuntu\n\n```bash\ncurl -fsSL https://ollama.com/install.sh | sh\n```\n\n### 3. Pull and Run Models\n\nTo pull and run the desired models:\n\n```bash\n# Pull models\nollama pull phi3:latest\nollama pull mistral:latest\nollama pull gemma:2b\nollama pull llama3:latest\n\n# Run models\nollama run phi3\nollama run mistral\nollama run gemma:2b\nollama run llama3\n```\n\n### 4. Manage Models\n\n```bash\n# List all pulled models\nollama list\n\n# Stop a running model\nollama stop phi3\n\n# View running models\nps aux | grep ollama\n```\n\n### 5. Shutdown Ubuntu\n\nFrom Ubuntu terminal:\n\n```bash\nshutdown now\n```\n\nOr simply close the terminal window if you don’t need a full shutdown.\n\n---\n\n## ☁️ Online Models via OpenRouter\n\n1. Go to [https://openrouter.ai](https://openrouter.ai) and **sign up**.\n\n2. Navigate to **API Keys** in your profile and **generate an API key**.\n\n3. Set this key as an environment variable in your API project:\n\n   ```bash\n   export OPENROUTER_API_KEY=your_key_here\n   ```\n\n4. Models used:\n\n   - `google/gemma-3-27b-it:free`\n   - `deepseek/deepseek-chat-v3-0324:free`\n\nAPI requests are routed via OpenRouter using this key, supporting seamless AI chat.\n\n---\n\n## 🤖 AIChatBot Integration\n\n### 🔧 Backend (API - .NET 8)\n\n1. Navigate to `AIChatBot.API/`\n2. Run the following commands:\n\n```bash\ndotnet restore\ndotnet build\ndotnet run\n```\n\n- Ensure `appsettings.json` file includes:\n\n```env\nApiKey=YOUR_KEY_HERE\n```\n\n### 💬 Frontend (UI - Angular 20)\n\n1. Navigate to `AIChatBot.UI/`\n2. Run:\n\n```bash\nnpm install\nng serve\n```\n\n- Access the chatbot UI at `http://localhost:4200/`\n\n---\n\n## 📚 RAG (Retrieval-Augmented Generation) Features\n\nThe AIChatBot includes advanced RAG capabilities that allow AI models to answer questions based on your uploaded documents. This feature significantly enhances the AI's ability to provide contextually relevant and accurate responses.\n\n### 🏗️ RAG Architecture\n\nThe RAG system consists of several key components:\n\n1. **Document Processing Pipeline**:\n   - File upload handling for multiple formats\n   - Text extraction from PDF, TXT, and MD files\n   - Content chunking for efficient retrieval\n   - In-memory indexing with similarity search\n\n2. **Retrieval System**:\n   - Semantic search across document chunks\n   - Top-K retrieval (configurable, default: 3 chunks)\n   - Relevance scoring and ranking\n   - Source attribution and metadata tracking\n\n3. **Generation Enhancement**:\n   - Context-aware prompt construction\n   - Integration with all supported AI models\n   - Source citation in responses\n   - Fallback to general knowledge when needed\n\n### 🎛️ RAG Configuration\n\nThe RAG system supports various AI models with different levels of effectiveness:\n\n| Model Category | Models | RAG Performance |\n|---------------|--------|-----------------|\n| **Best RAG Support** | GPT-3.5 Turbo\u003cbr\u003eGemini Flash 2.0 (Unlimited)\u003cbr\u003eGemini Flash 2.0 (Limited) | ⭐⭐⭐⭐⭐ |\n| **Good RAG Support** | DeepSeek v3\u003cbr\u003eGemma 3 27B\u003cbr\u003eLLaMA 3 | ⭐⭐⭐⭐ |\n| **Basic RAG Support** | PHI-3\u003cbr\u003eMistral 7B | ⭐⭐⭐ |\n\n### 🚀 Using RAG Features\n\n1. **Upload Documents**:\n   ```bash\n   # Supported formats\n   - Plain text files (.txt)\n   - Markdown files (.md) \n   - PDF documents (.pdf)\n   ```\n\n2. **Document Management**:\n   - View all uploaded documents\n   - Delete individual documents\n   - User-specific document collections\n   - Automatic indexing upon upload\n\n3. **RAG-Enhanced Chat**:\n   - Select \"Knowledge-Based (RAG)\" mode\n   - Ask questions about your uploaded content\n   - Receive responses with source attribution\n   - Contextual answers based on document content\n\n### 💾 Document Storage\n\nCurrently, the RAG system uses in-memory storage (`InMemoryRagStore`), which provides:\n- Fast retrieval performance\n- Simple deployment setup\n- Automatic cleanup on application restart\n- User-isolated document collections\n\n*Note: For production deployments, consider implementing persistent storage solutions.*\n\n---\n\n## 🧪 Model \u0026 Environment Summary\n\n| Model                          | Type   | Source        | Access       | RAG Support |\n| ------------------------------ | ------ | ------------- | ------------ | ----------- |\n| PHI-3\\:latest                  | Local  | Ollama        | `ollama run` | ⭐⭐⭐       |\n| Mistral\\:latest                | Local  | Ollama        | `ollama run` | ⭐⭐⭐       |\n| Gemma:2b                       | Local  | Ollama        | `ollama run` | ⭐⭐⭐       |\n| Llama3\\:latest                 | Local  | Ollama        | `ollama run` | ⭐⭐⭐⭐     |\n| google/gemma-3-27b-it\\:free    | Online | OpenRouter.ai | API Key      | ⭐⭐⭐⭐     |\n| deepseek/deepseek-chat-v3-0324 | Online | OpenRouter.ai | API Key      | ⭐⭐⭐⭐     |\n| google/gemini-2.0-flash-exp    | Online | OpenRouter.ai | API Key      | ⭐⭐⭐⭐⭐   |\n| openai/gpt-3.5-turbo-0613      | Online | OpenRouter.ai | API Key      | ⭐⭐⭐⭐⭐   |\n| google/gemini-2.0-flash-001    | Online | OpenRouter.ai | API Key      | ⭐⭐⭐⭐⭐   |\n\n---\n\n## 📂 Project Structure\n\n```\nAIChatBot/\n│\n├── AIChatBot.API/           # .NET 8 API for chatbot\n│   ├── Controllers/         # API endpoints\n│   │   └── DocumentsController.cs    # RAG document upload/management\n│   ├── Services/           # Business logic services\n│   │   ├── RagChatService.cs         # RAG-enabled chat functionality\n│   │   ├── InMemoryRagStore.cs       # Document indexing and search\n│   │   ├── AgentService.cs           # AI tool integration\n│   │   └── ChatService.cs            # Standard chat functionality\n│   ├── Interfaces/         # Service contracts\n│   │   └── IRagStore.cs              # RAG storage interface\n│   └── Migrations/         # Database schema updates for RAG\n├── AIChatBot.UI/           # Angular 20 UI frontend\n│   └── src/app/components/\n│       ├── document-upload/          # RAG document upload component\n│       ├── chat/                     # Main chat interface\n│       └── model-selector/           # AI model and mode selection\n└── README.md               # Project documentation\n```\n\n---\n## 🧠 AI Tools \u0026 Agent Integration\n\nThe AIChatBot supports three advanced operation modes beyond simple chat:\n\n### 1. 🛠️ Tool-Enabled AI\nIn this mode, the AI can recognize specific tasks in user prompts and use internal tools (functions) to perform actions. Integrated tools include:\n\n| Tool Function    | Description                                  | Example Prompt                                                   |\n|------------------|----------------------------------------------|------------------------------------------------------------------|\n| `CreateFile`     | Creates a text file with given content       | \"Create a file called `report.txt` with the text `Hello world`.\" |\n| `FetchWebData`   | Fetches the HTML/content of a public URL     | \"Fetch the content of https://example.com\"                       |\n| `SendEmail`      | Simulates sending an email (console-logged)  | \"Send an email to john@example.com with subject `Hello`.\"        |\n\nThese functions are executed server-side in `.NET`, with input parsed from natural language prompts.\n\n### 2. 📚 Knowledge-Based (RAG) Mode\n**NEW FEATURE:** The RAG (Retrieval-Augmented Generation) mode enables AI to answer questions based on your uploaded documents. This powerful feature allows you to:\n\n#### 🎯 Key Capabilities:\n- **Upload Documents**: Support for `.txt`, `.md`, and `.pdf` files\n- **Intelligent Retrieval**: Automatically finds relevant content from your documents\n- **Source Attribution**: AI responses include references to source documents\n- **Document Management**: View, organize, and delete uploaded documents\n- **User-Specific Storage**: Each user has their own document collection\n\n#### 📄 Supported File Formats:\n- **Text Files**: `.txt` - Plain text documents\n- **Markdown Files**: `.md` - Formatted markdown documents  \n- **PDF Documents**: `.pdf` - Portable document format\n\n#### 🚀 How to Use RAG Mode:\n1. **Upload Documents**: Use the drag-and-drop interface or browse to upload documents\n2. **Select RAG Mode**: Choose \"Knowledge-Based (RAG)\" from the chat mode dropdown\n3. **Ask Questions**: Query your documents using natural language\n4. **Get Contextual Answers**: Receive AI responses enriched with your document content\n\n#### 💡 Example RAG Interaction:\n```\nUser: \"What are the key findings in the latest market report?\"\nAI: Based on the provided context from \"market_analysis_2025.pdf\", the key findings include:\n1. Consumer spending increased by 15% in Q4\n2. Digital transformation investments rose by 23%\n3. Supply chain disruptions decreased significantly\n\n*Sources: 1 document(s) referenced*\n```\n\n### 3. 🤖 AI Agent Mode (Planning + Action)\nThe AI agent is capable of:\n- Understanding high-level tasks\n- Selecting and invoking appropriate tools\n- Providing intelligent responses based on the outcome\n\nThis is powered by an `AgentService` that works with both **local LLMs** (via Ollama) and **cloud models** (via OpenRouter) to determine the right function to execute and handle the response.\n\nYou can toggle between AI modes via the UI:\n- **Chat-Only Mode**\n- **AI + Tools Mode**\n- **Knowledge-Based (RAG) Mode**\n- **Agent Mode** (multi-step planning, coming soon)\n\n---\n\n## 🚀 Get Started\n\n### Quick Start Guide\n\n1. **Choose your preferred model type** (local or online)\n2. **Start the backend** using `.NET 8`\n3. **Start the frontend** using Angular CLI  \n4. **Access AIChatBot** at `http://localhost:4200/`\n\n### Using RAG Features (NEW!)\n\n5. **Upload Documents**: \n   - Click the \"Documents for RAG\" section in the sidebar\n   - Drag \u0026 drop or browse to upload `.txt`, `.md`, or `.pdf` files\n   - Wait for successful upload confirmation\n\n6. **Enable Knowledge-Based Mode**:\n   - Select \"Knowledge-Based (RAG)\" from the chat mode dropdown\n   - Choose an AI model with good RAG support (⭐⭐⭐⭐ or ⭐⭐⭐⭐⭐)\n\n7. **Start Asking Questions**:\n   ```\n   Examples:\n   \"Summarize the key points from my uploaded documents\"\n   \"What does the report say about market trends?\"\n   \"Find information about [specific topic] in my files\"\n   ```\n\n8. **Review Source Attribution**:\n   - AI responses will include \"*Sources: X document(s) referenced*\"\n   - Responses are enriched with content from your uploaded documents\n\n---\n\n## 💖 Contributing\n\nPull requests and suggestions are welcome! Feel free to fork the repo and enhance it.\n\n---\n\n## 📄 License\n\nThis project is open-source and available under the [MIT License](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardikpatelse%2Faichatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardikpatelse%2Faichatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardikpatelse%2Faichatbot/lists"}