FonsecaFramework.Ai
2026.7.31.1
dotnet add package FonsecaFramework.Ai --version 2026.7.31.1
NuGet\Install-Package FonsecaFramework.Ai -Version 2026.7.31.1
<PackageReference Include="FonsecaFramework.Ai" Version="2026.7.31.1" />
<PackageVersion Include="FonsecaFramework.Ai" Version="2026.7.31.1" />
<PackageReference Include="FonsecaFramework.Ai" />
paket add FonsecaFramework.Ai --version 2026.7.31.1
#r "nuget: FonsecaFramework.Ai, 2026.7.31.1"
#:package FonsecaFramework.Ai@2026.7.31.1
#addin nuget:?package=FonsecaFramework.Ai&version=2026.7.31.1
#tool nuget:?package=FonsecaFramework.Ai&version=2026.7.31.1
FonsecaFramework.Ai
AI and machine learning utilities for .NET applications.
Overview
FonsecaFramework.Ai is a .NET 10 library that provides tools for building ML models with AutoML, performing sentiment/discourse analysis, implementing RAG (Retrieval‑Augmented Generation) vector stores, and integrating with LLM providers via the Microsoft.Extensions.AI abstraction. It wraps ML.NET and ONNX Runtime to offer a streamlined API for training, predicting, and exporting models.
Installation
dotnet add package FonsecaFramework.Ai
Features
| Area | Key Classes |
|---|---|
| AutoML Model Building | AiModelBuilder<T> — build regression, classification, ranking, and recommendation models with ML.NET AutoML |
| Trained Model | AiModel<T, TMetrics> — make predictions and export to ONNX format |
| RAG Vector Store | RagVectorStore — chunk documents, build TF-IDF + discourse vectors, and retrieve context for LLM prompts |
| Agent Framework RAG Bridge | RagVectorStore.CreateTextSearchProvider(...) — expose store retrieval through Microsoft.Agents.AI.TextSearchProvider |
| RAG Snapshots | RagVectorStoreSnapshot — serialize/deserialize a vector store to avoid re-processing documents |
| Sentiment Analysis | ISentimentAnalyzer — 10-element discourse vector interface |
LexiconSentimentAnalyzer — fast, deterministic, lexicon-based analyzer (no external service required) |
|
OllamaSentimentAnalyzer — LLM-powered analyzer via IChatClient with lexicon fallback |
|
| LLM Chat Client | VLRChatClient — IChatClient implementation for OpenAI-compatible endpoints (e.g. Ollama) with streaming support |
| ACP Subagents | IAgentOrchestrator — delegates planner-selected work to local Agent Client Protocol (ACP) subagents over stdio |
Examples
Build and Use a Regression Model
using FonsecaFramework.Ai;
var data = new List<HouseData>
{
new() { Size = 1000, Price = 200_000 },
new() { Size = 1500, Price = 300_000 },
new() { Size = 2000, Price = 400_000 },
// ... more training data
};
var builder = new AiModelBuilder<HouseData>(data, nameof(HouseData.Price));
var model = builder.BuildRegressionModel(
MaxExperimentTimeInSeconds: 30);
float prediction = model.Predict(new HouseData { Size = 1750 });
Console.WriteLine($"Predicted price: {prediction:C}");
// Export to ONNX
await model.ConvertToOnnx("house-model.onnx");
Build a Binary Classification Model
using FonsecaFramework.Ai;
var data = new List<EmailData>
{
new() { Subject = "Free money!", Body = "Click here now", IsSpam = true },
new() { Subject = "Meeting tomorrow", Body = "See you at 3pm", IsSpam = false },
// ... more training data
};
var builder = new AiModelBuilder<EmailData>(data, nameof(EmailData.IsSpam));
var model = builder.BuildBinaryClassificationModel(MaxExperimentTimeInSeconds: 60);
float score = model.Predict(new EmailData { Subject = "You won!", Body = "Claim prize" });
Console.WriteLine($"Spam score: {score}");
RAG Vector Store — Build and Query
using FonsecaFramework.Ai;
// Build from a folder of .txt documents (optional sentiment analyzer can be supplied)
var store = await RagVectorStore.Build(
sourceFolder: "./docs",
chunkSize: 512,
chunkOverlap: 128);
// Augment a user prompt with relevant context (async lookup)
string augmentedPrompt = await store.LookupAsync(
query: "How do I configure the database?",
topK: 3);
Console.WriteLine(augmentedPrompt);
// The prompt now includes the most relevant document chunks as context
RAG with LLM-Powered Sentiment Analysis
using FonsecaFramework.Ai;
using FonsecaFramework.Ai.LLM;
// Use Ollama for richer discourse analysis
var chatClient = new VLRChatClient("http://localhost:11434");
var sentimentAnalyzer = new OllamaSentimentAnalyzer(chatClient);
var store = await RagVectorStore.Build(
sourceFolder: "./docs",
sentimentAnalyzer: sentimentAnalyzer);
// Retrieve relevant chunks (no built‑in sentiment filter yet)
string result = await store.LookupAsync(
query: "What safety precautions should I take?",
topK: 5);
Agent Framework Integration (TextSearchProvider)
using FonsecaFramework.Ai;
using Microsoft.Agents.AI;
var store = await RagVectorStore.Build("./docs");
// Basic wrapper for Microsoft Agent Framework RAG pattern
var provider = store.CreateTextSearchProvider(
options: new TextSearchProviderOptions
{
SearchTime = TextSearchProviderOptions.TextSearchBehavior.BeforeAIInvoke
},
topK: 3,
minSimilarity: 0.05);
// Optional: direct adapter usage if you need raw search results
var results = await store.SearchTextResultsAsync("refund policy", topK: 3);
Sentiment / Discourse Analysis
using FonsecaFramework.Ai;
var analyzer = new LexiconSentimentAnalyzer();
float[] vector = await analyzer.AnalyzeAsync(
"Warning: Do not operate the machine without safety equipment.");
// vector is a 10-element array:
// [positive, negative, instructional, technical, cautionary,
// informational, urgency, formality, specificity, actionability]
string category = analyzer.Classify(vector);
Console.WriteLine($"Dominant category: {category}"); // "cautionary"
VLRChatClient — OpenAI-Compatible LLM Integration
using FonsecaFramework.Ai.LLM;
using Microsoft.Extensions.AI;
using var client = new VLRChatClient("http://localhost:11434");
var messages = new[]
{
new ChatMessage(ChatRole.System, "You are a helpful assistant."),
new ChatMessage(ChatRole.User, "Explain dependency injection in one paragraph.")
};
var response = await client.GetResponseAsync(messages);
Console.WriteLine(response.Text);
ACP Subagent Delegation
Configure local ACP-compatible agent processes when registering the orchestration stack. The planner selects an agent through ToolInvocation.AgentName and may run work concurrently only by assigning the same non-empty ParallelGroup to independent invocations. Dependencies are expressed through DependsOnInvocationIds.
services.AddFonsecaAiOrchestration(options =>
{
options.MaxSubagentConcurrency = 3;
options.AcpAgents.Add(new AcpAgentDefinition
{
Name = "research",
Command = "my-acp-agent",
Arguments = ["--stdio"]
});
});
ACP subagents are launched as local child processes with redirected standard input and output. Configure only trusted executables, avoid placing secrets in command-line arguments, and restrict agent working directories and inherited environment variables. The ACP client is isolated behind IAcpTransport; an HTTP transport can be added later without changing orchestration callers.
Requirements
- .NET 10.0
- For
OllamaSentimentAnalyzer/VLRChatClient: an OpenAI-compatible LLM endpoint (e.g. Ollama)
License
Copyright 2026 Steven Fonseca / VLR Creations
Licensed under the Apache License, Version 2.0. You may use this library free of charge, provided you include the required attribution notices. See the LICENSE file for full terms.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Azure.Identity (>= 1.21.0)
- FonsecaFramework (>= 2026.7.31.1)
- MathNet.Numerics (>= 5.0.0)
- Microsoft.Agents.AI (>= 1.15.0)
- Microsoft.Bcl.Memory (>= 10.0.10)
- Microsoft.Data.SqlClient (>= 7.0.2)
- Microsoft.Extensions.AI (>= 10.8.3)
- Microsoft.Extensions.ML (>= 5.0.0)
- Microsoft.ML (>= 5.0.0)
- Microsoft.ML.AutoML (>= 0.23.0)
- Microsoft.ML.OnnxConverter (>= 0.23.0)
- Microsoft.ML.OnnxRuntime (>= 1.28.0)
- Microsoft.ML.OnnxTransformer (>= 5.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FonsecaFramework.Ai:
| Package | Downloads |
|---|---|
|
FonsecaFramework.Asp
Base classes and extensions for ASP.NET Core web applications, offering a fluent builder API, MVC/Razor helpers, Swagger, OAuth2/JWT auth, background services, and AI‑driven dynamic rate limiting. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.7.31.1 | 0 | 7/31/2026 |
| 2026.7.30.2 | 33 | 7/30/2026 |
| 2026.7.30.1 | 37 | 7/30/2026 |
| 2026.7.10.1 | 141 | 7/10/2026 |
| 2026.7.8.1 | 129 | 7/8/2026 |
| 2026.7.1.1 | 139 | 7/1/2026 |
| 2026.6.28.1 | 143 | 6/29/2026 |
| 2026.6.18.1 | 154 | 6/18/2026 |
| 2026.6.13.1 | 151 | 6/13/2026 |
| 2026.6.4.2 | 153 | 6/4/2026 |
| 2026.6.4.1 | 143 | 6/4/2026 |
| 2026.6.3.3 | 149 | 6/4/2026 |
| 2026.6.3.2 | 159 | 6/4/2026 |
| 2026.6.3.1 | 147 | 6/3/2026 |
| 2026.5.21.1 | 144 | 5/22/2026 |
| 2026.5.20.1 | 150 | 5/20/2026 |
| 2026.5.12.1 | 150 | 5/13/2026 |
| 2026.5.11.1 | 154 | 5/11/2026 |
| 2026.5.7.2 | 150 | 5/7/2026 |
| 2026.5.7.1 | 143 | 5/7/2026 |