TCM.InAppAuth 1.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package TCM.InAppAuth --version 1.0.7
                    
NuGet\Install-Package TCM.InAppAuth -Version 1.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TCM.InAppAuth" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TCM.InAppAuth" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="TCM.InAppAuth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TCM.InAppAuth --version 1.0.7
                    
#r "nuget: TCM.InAppAuth, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TCM.InAppAuth@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TCM.InAppAuth&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=TCM.InAppAuth&version=1.0.7
                    
Install as a Cake Tool

TCM.InAppAuth

A shared library for AI integration using LM Studio in the TCM application suite.

Features

  • LM Studio Integration: Connect to LM Studio server for AI chat completions
  • Prompt Management: Store and retrieve AI prompts from the InAppAuth database
  • Easy Integration: Simple extension methods for service registration

Installation

Add a project reference to TCM.InAppAuth in your project:

<ProjectReference Include="..\..\..\shareds\TCM.InAppAuth\TCM.InAppAuth.csproj" />

Configuration

appsettings.json

Add the following configuration to your appsettings.json:

{
  "ConnectionStrings": {
    "InAppAuthConnection": "Server=your-server;Database=InAppAuth;User Id=your-user;Password=your-password;TrustServerCertificate=True"
  },
  "LMStudio": {
    "BaseUrl": "http://localhost:1234",
    "DefaultModel": "your-default-model-id",
    "DefaultMaxTokens": 2048,
    "DefaultTemperature": 0.7,
    "TimeoutSeconds": 120,
    "ApiKey": ""
  }
}

Service Registration

In your Program.cs or Startup.cs:

using TCM.InAppAuth.Extensions;

// Option 1: Add all TCM.InAppAuth services including database
builder.Services.AddTCMAIWithDatabase(builder.Configuration);

// Option 2: Add only LM Studio services (without database)
builder.Services.AddTCMAI(builder.Configuration);

// Option 3: Add only database context (without LM Studio services)
builder.Services.AddInAppAuthDbContext(builder.Configuration);

Usage

Basic Chat Completion

using TCM.InAppAuth.Services;
using TCM.InAppAuth.Models;

public class MyService
{
    private readonly ILMStudioService _lmStudioService;

    public MyService(ILMStudioService lmStudioService)
    {
        _lmStudioService = lmStudioService;
    }

    public async Task<string> GetAIResponse(string userMessage)
    {
        var result = await _lmStudioService.SendMessageAsync(
            message: userMessage,
            systemMessage: "You are a helpful assistant."
        );

        if (result.Success)
        {
            return result.Content;
        }
        
        throw new Exception(result.ErrorMessage);
    }
}

Using Stored Prompts

// First, add a prompt to the InAppAuth database
// Then use it by promptCode:

var result = await _lmStudioService.SendPromptAsync(
    promptCode: "QUALITY_CHECK",
    userInput: "Check this product description for quality issues."
);

Advanced Chat Completion

var request = new ChatCompletionRequest
{
    Model = "your-model-id",
    Messages = new List<ChatMessage>
    {
        ChatMessage.System("You are an expert in manufacturing."),
        ChatMessage.User("What are best practices for quality control?")
    },
    MaxTokens = 1000,
    Temperature = 0.5m
};

var result = await _lmStudioService.ChatCompletionAsync(request);

Managing Prompts

using TCM.InAppAuth.Repositories;
using TCM.InAppAuth.Entities;

public class PromptService
{
    private readonly IAIPromptRepository _promptRepository;

    public PromptService(IAIPromptRepository promptRepository)
    {
        _promptRepository = promptRepository;
    }

    public async Task CreatePrompt()
    {
        var prompt = new AIPrompt
        {
            PromptCode = "PRODUCTION_ANALYSIS",
            Prompt = "Analyze the following production data and provide insights:",
            ModelId = "your-model-id",
            Description = "Analyze production data",
            SystemMessage = "You are a production analyst expert.",
            MaxTokens = 2000,
            Temperature = 0.7m
        };

        await _promptRepository.AddAsync(prompt);
    }
}

Database Schema

The InAppAuth database contains the following table:

AIPrompt

Column Type Description
Id int Primary key
PromptCode nvarchar(100) Unique identifier for the prompt
Prompt nvarchar(max) The prompt text
ModelId nvarchar(200) AI model identifier
Description nvarchar(500) Optional description
SystemMessage nvarchar(max) Optional system message
MaxTokens int Maximum response tokens
Temperature decimal(3,2) Response randomness (0.0-2.0)
IsActive bit Active status
CreatedDate datetime Creation timestamp
ModifiedDate datetime Last modification timestamp
CreatedUserId uniqueidentifier Creator user ID
ModifiedUserId uniqueidentifier Last modifier user ID

Project Structure

TCM.InAppAuth/
├── Contexts/
│   └── InAppAuthDbContext.cs          # Database context for InAppAuth
├── Entities/
│   └── AIPrompt.cs               # Prompt entity
├── EntityConfigurations/
│   └── AIPromptConfiguration.cs  # EF Core configuration
├── Extensions/
│   └── ServiceCollectionExtensions.cs  # DI extensions
├── Models/
│   ├── AICompletionResult.cs     # Completion result model
│   ├── ChatCompletionRequest.cs  # API request model
│   ├── ChatCompletionResponse.cs # API response model
│   └── ChatMessage.cs            # Chat message model
├── Repositories/
│   ├── AIPromptRepository.cs     # Repository implementation
│   └── IAIPromptRepository.cs    # Repository interface
├── Services/
│   ├── ILMStudioService.cs       # Service interface
│   └── LMStudioService.cs        # Service implementation
├── Settings/
│   └── LMStudioSettings.cs       # Configuration settings
└── TCM.InAppAuth.csproj           # Project file

Environment Variables

For non-development environments, the following environment variables are used:

  • InAppAuthConnection: Connection string for the InAppAuth database
  • ASPNETCORE_ENVIRONMENT: Environment name (Development, Staging, Production)
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TCM.InAppAuth:

Package Downloads
TCM.Tasks

Task scheduling library for TCM projects, built on Quartz.NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.24 30 6/8/2026
1.0.23 49 6/8/2026
1.0.22 47 6/6/2026
1.0.21 125 6/2/2026
1.0.20 112 6/2/2026
1.0.19 93 5/28/2026
1.0.18 92 5/28/2026
1.0.17 96 5/26/2026
1.0.16 126 5/26/2026
1.0.15 111 5/24/2026
1.0.14 88 5/24/2026
1.0.13 85 5/24/2026
1.0.12 90 5/24/2026
1.0.11 90 5/24/2026
1.0.10 98 5/24/2026
1.0.9 103 5/23/2026
1.0.8 98 5/23/2026
1.0.7 98 5/23/2026
1.0.6 99 5/19/2026
1.0.5 90 5/18/2026
Loading failed