CoreTemplate.AI
1.4.0
dotnet add package CoreTemplate.AI --version 1.4.0
NuGet\Install-Package CoreTemplate.AI -Version 1.4.0
<PackageReference Include="CoreTemplate.AI" Version="1.4.0" />
<PackageVersion Include="CoreTemplate.AI" Version="1.4.0" />
<PackageReference Include="CoreTemplate.AI" />
paket add CoreTemplate.AI --version 1.4.0
#r "nuget: CoreTemplate.AI, 1.4.0"
#:package CoreTemplate.AI@1.4.0
#addin nuget:?package=CoreTemplate.AI&version=1.4.0
#tool nuget:?package=CoreTemplate.AI&version=1.4.0
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 | Versions 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. |
-
net9.0
- FluentValidation (>= 12.0.0)
- MediatR (>= 9.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.7)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.7)
- Microsoft.Extensions.Options (>= 9.0.7)
- Microsoft.SemanticKernel (>= 1.60.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.