LmsSharp.Hosting
1.0.5
dotnet add package LmsSharp.Hosting --version 1.0.5
NuGet\Install-Package LmsSharp.Hosting -Version 1.0.5
<PackageReference Include="LmsSharp.Hosting" Version="1.0.5" />
<PackageVersion Include="LmsSharp.Hosting" Version="1.0.5" />
<PackageReference Include="LmsSharp.Hosting" />
paket add LmsSharp.Hosting --version 1.0.5
#r "nuget: LmsSharp.Hosting, 1.0.5"
#:package LmsSharp.Hosting@1.0.5
#addin nuget:?package=LmsSharp.Hosting&version=1.0.5
#tool nuget:?package=LmsSharp.Hosting&version=1.0.5
Lightweight hosting and DI helpers for integrating LM Studio into .NET apps. Wraps the LmsSharp client with convenient services and a BackgroundService for health checks, chat, streaming, structured output, and tool use.
Installation
From Source
Build the project locally:
git clone https://github.com/Ddemon26/Lmss.git
cd Lmss/Lmss.Hosting
dotnet build
NuGet Package
dotnet add package LmsSharp.Hosting
Local Development
Reference the project directly in your .csproj
:
<ProjectReference Include="path/to/Lmss.Hosting/Lmss.Hosting.csproj" />
Requirements
- .NET 8.0
- LM Studio running locally (default: http://localhost:1234)
Quick Start
Option 1: One‑liner factory
using Lmss.Hosting;
var service = ServiceFactory.Create();
var reply = await service.SendMessageAsync("Hello LM Studio!");
Console.WriteLine(reply);
Option 2: Dependency Injection (service helper)
using Lmss.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
// Registers ILmss + LmssService and optional settings
services.AddService(opts =>
{
// Example: configure base URL or model
// opts.BaseUrl = "http://localhost:1234";
// opts.DefaultModel = "your-model-name";
});
})
.Build();
await host.StartAsync();
var svc = host.Services.GetRequiredService<LmssService>();
var response = await svc.SendMessageAsync("Hi there!");
Console.WriteLine(response);
await host.StopAsync();
Option 3: Background service
The package includes LmssHostedService
, which continuously monitors readiness and can be extended for custom workflows.
using Lmss.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
// Registers ILmss and the background hosted service
services.AddHostedService(opts =>
{
// opts.BaseUrl = "http://localhost:1234";
});
})
.Build();
await host.RunAsync();
To customize periodic background work, subclass LmssHostedService
and override OnBackgroundExecuteAsync
.
Features
- Dependency injection:
AddClient
,AddService
,AddHostedService
- Background processing with readiness checks and logging
- Chat completions (simple and streaming)
- Structured JSON output using schemas
- Tool use/function calling workflow
- Model management and health checks
Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
License
This project is licensed under the MIT License — see the LICENSE
file for details.
Support
- LM Studio Docs: https://lmstudio.ai/docs
- GitHub Issues: https://github.com/Ddemon26/Lmss/issues
- API Reference: https://github.com/Ddemon26/Lmss/wiki
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- LmsSharp (>= 1.0.5)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- System.Text.Json (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.