CoreTemplate.AI 1.4.0

dotnet add package CoreTemplate.AI --version 1.4.0
                    
NuGet\Install-Package CoreTemplate.AI -Version 1.4.0
                    
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="CoreTemplate.AI" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreTemplate.AI" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="CoreTemplate.AI" />
                    
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 CoreTemplate.AI --version 1.4.0
                    
#r "nuget: CoreTemplate.AI, 1.4.0"
                    
#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 CoreTemplate.AI@1.4.0
                    
#: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=CoreTemplate.AI&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=CoreTemplate.AI&version=1.4.0
                    
Install as a Cake Tool

CoreTemplate.AI

A modular, strategy-based AI abstraction layer for .NET that supports multiple AI providers like OpenRouter and Ollama, with support for real-time streaming, semantic memory, dynamic model validation, runtime provider switching, and now — Function Calling.


🔔 What's New in 1.4.0

🧠 Function Calling Support

This version introduces built-in support for AI Function Calling, enabling your .NET backend to handle function invocations requested by the AI model.

Whether using OpenRouter’s tool_calls or Ollama’s tools, your registered C# methods can now be discovered and executed in response to a prompt.


✨ Example Usage

1. Define your function
[Function("get_server_time", "Returns current server time")]
public static object GetServerTime() => new { time = DateTime.UtcNow };

2. Register Your Function Registry

Create a class implementing IFunctionRegistry:

public class MyFunctionRegistry : IFunctionRegistry
{
    public IEnumerable<AiFunction> GetAll()
    {
        yield return new AiFunction(typeof(MyFunctions).GetMethod(nameof(MyFunctions.GetServerTime))!);
    }
}


Then register it in Startup.cs or Program.cs:

services.AddSingleton<IFunctionRegistry, MyFunctionRegistry>();

3. Inject and Call the AI Service

Use the IAIService to invoke a prompt that will trigger your registered function:

var result = await _aiService.GetCompletionAsync("What time is it right now?");
Console.WriteLine(result);

4. Sample AI Response (JSON)
{
  "Content": "Function get_server_time executed successfully.",
  "FunctionExecuted": true,
  "FunctionName": "get_server_time",
  "FunctionResult": {
    "time": "2025-08-20T10:14:28Z"
  }
}

📦 Installation

Install the latest version via NuGet:

dotnet add package CoreTemplate.AI --version 1.4.0

⚙️ Configuration (appsettings.json)
"AiSettings": {
  "Provider": "OpenRouter",
  "Model": "gpt-3.5-turbo"
},
"OpenRouter": {
  "ApiKey": "your-openrouter-api-key"
},
"Ollama": {
  "BaseUrl": "http://localhost:11434"
},
]
Product Compatible and additional computed target framework versions.
.NET 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 132 8/20/2025
1.3.0 137 7/9/2025
1.2.0 134 7/8/2025
1.1.1 140 7/3/2025
1.1.0 226 7/3/2025 1.1.0 is deprecated because it is no longer maintained.