Skip to content

raminesfahani/LangMate

Repository files navigation

LangMate

Build & Publish NuGet Packages License: MIT Language GitHub Repo stars NuGet


LangMate is a modular and extensible AI chat application and SDK platform built with .NET 9 and fully compatible with .NET Aspire.
It provides a Blazor-powered Web UI, Ollama model integrations, persistent chat history via MongoDB, and a flexible SDK for .NET developers to integrate and use local LLMs (like Gemma, LLaMA2, Mistral) easily and securely.


🌟 Key Features

  • βš™οΈ Fully compatible with .NET Aspire
  • πŸ’¬ Chat UI
    • built with Blazor Server (interactive, reactive experience)
  • 🧠 Ollama Integration
    • LLM-based completion and conversation
  • πŸ—ƒ MongoDB Chat History and caching
    • for persistent and fast retrieval
  • πŸ”§ LangMate.Core SDK
    • use Ollama easily in your own .NET apps
  • 🧩 Pluggable Middleware
    • Polly-powered Resiliency, Circuit Breakers, and Retry logic
  • πŸš€ File Upload Support
    • with base64 image preview support (for image input models)
  • 🌐 API Endpoints
    • Implemented a backend-driven project for using in every client app
  • 🧰 Developer-Friendly architecture β€” clean, testable and maintainable

🧠 Architecture

LangMate/
β”œβ”€β”€ Apps/
β”œβ”€β”€β”€β”€ LangMate.AppHost.AppHost        β†’ .NET Aspire for orchestrating and deploying the apps on Docker, Kubernetes, or any other cloud platform.
β”œβ”€β”€β”€β”€ LangMate.AppHost.BlazorUI        β†’ Blazor ChatBot UI sample project using LangMate SDK
β”œβ”€β”€β”€β”€ LangMate.AppHost.ApiService        β†’ Web API sample project using LangMate SDK
β”œβ”€β”€ SDK/
β”œβ”€β”€β”€β”€ LangMate.Core               β†’ Reusable .NET SDK to interact with Ollama
β”œβ”€β”€β”€β”€ LangMate.Middleware         β†’ Polly-based Resiliency Middleware (retry, timeout, circuit breaker)
β”œβ”€β”€β”€β”€ LangMate.Extensions         β†’ Utilities, helpers and extension methods
β”œβ”€β”€β”€β”€ LangMate.Persistence        β†’ MongoDB chat history, caching layer, repositories and configuration

πŸ“¦ Installation

Prerequisites

Run the App

git clone https://github.com/raminesfahani/LangMate.git
cd LangMate/src/apps/LangMate.AppHost.AppHost

# Restore dependencies and build
dotnet restore
dotnet build

# Run the .NET Aspire Dashboard
dotnet run

Then open https://localhost:17198/ in your browser to see the .NET Aspire dashboard. You can launch Blazor ChatBot or Web API apps over there by their own links.


LangMate.Core SDK

LangMate.Core is a lightweight, extensible .NET SDK designed to make working with Ollama-powered local AI models seamless and developer-friendly. It abstracts away the complexity of managing conversations, interacting with Ollama endpoints, and persisting chat history β€” all while offering resiliency, caching, and extensibility.

πŸ“¦ Installation

To use LangMate.Core, install the required NuGet package NuGet, or include the project reference in your solution.

dotnet add package LangMate.Core

βœ… Sample Usage

You can see Full Documentation and sample usage in this link as well.


🧠 LangMate Blazor Chat UI

The LangMate Blazor App is an intelligent, real-time chat UI built with Blazor Server and integrated with the powerful local AI models provided by Ollama using LangMate.Core SDK.

It provides a complete frontend experience for interacting with AI models, managing chat history, uploading files, and dynamically updating chat state.

✨ Features

  • πŸ” Chat with Ollama Models: Seamlessly send and stream messages from local Ollama instances.

  • πŸ’¬ Persistent Conversations: Every chat session is stored in MongoDB and can be resumed anytime.

  • πŸ“‚ File Uploads: Upload image files and pass them to models like llava for multimodal interactions.

  • 🧭 Sidebar Navigation: Access previous chats and start new ones from a clean sidebar UI.

  • πŸ“¦ Model Switching: Easily switch between available Ollama models.

  • πŸ”ƒ Streaming Responses: Uses async streaming to display tokens as they’re generated.

  • ☁️ Resilient Middleware: Protected with timeout, retry, and circuit breaker policies.

  • πŸ”” Global Error Toasts: All unhandled exceptions surface as toast notifications.

Screenshots

LangMate Blazor Chat UI - Home Page

LangMate Blazor Chat UI - Chat user interface

LangMate Blazor Chat UI - Sample chat

πŸ“‘ LangMate WebAPI

The LangMate API Service is the backend layer of the LangMate system, exposing RESTful HTTP APIs for external integration, orchestration, and automation.

It serves as a stateless gateway for interacting with the LangMate core functionalities β€” such as chat sessions, file uploads, model management, and streaming chat completions β€” powered by the LangMate.Core SDK and Ollama.

✨ Features

  • πŸ”— Chat Completion API: Start or continue chat sessions supporting stream mode with local Ollama models.

  • 🧠 Model Discovery: Query available and pulled models from the Ollama runtime.

  • πŸ’¬ Conversation APIs: Read, delete, and manage persistent chat history.

  • πŸ–ΌοΈ File Upload: Upload image files to be used with multimodal models (e.g., gemma).

  • πŸ” Middleware-Enhanced Resilience: Protected by retry, timeout, and circuit breaker policies via LangMate.Middleware.

  • βš™οΈ Scalar Integration: Auto-generated OpenAPI documentation (easily added).


LangMate Web API documentation

πŸ› οΈ Build and Test

dotnet build --configuration Release
dotnet test

πŸ“¬ Contributing

Contributions are welcome!

  1. Fork the repo and create your branch
  2. Implement your feature or fix
  3. Submit a PR with proper context

πŸ“„ License

Licensed under the MIT License.


πŸ“£ Contact

Created and maintained by @raminesfahani.
For issues and features, open a GitHub Issue.


πŸ™ Acknowledgements

This project uses the Ollama repository for local AI model integration. I am thankful to the maintainers and contributors of Ollama for making this technology available.

About

LangMate is a modular and extensible AI chat application and .NET SDK platform built with .NET 9 and fully compatible with .NET Aspire to integrate and use local LLMs (like Gemma, LLaMA2, Mistral).

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages