![]() |
VOOZH | about |
dotnet add package FonsecaFramework.Ai --version 2026.6.18.1
NuGet\Install-Package FonsecaFramework.Ai -Version 2026.6.18.1
<PackageReference Include="FonsecaFramework.Ai" Version="2026.6.18.1" />
<PackageVersion Include="FonsecaFramework.Ai" Version="2026.6.18.1" />Directory.Packages.props
<PackageReference Include="FonsecaFramework.Ai" />Project file
paket add FonsecaFramework.Ai --version 2026.6.18.1
#r "nuget: FonsecaFramework.Ai, 2026.6.18.1"
#:package FonsecaFramework.Ai@2026.6.18.1
#addin nuget:?package=FonsecaFramework.Ai&version=2026.6.18.1Install as a Cake Addin
#tool nuget:?package=FonsecaFramework.Ai&version=2026.6.18.1Install as a Cake Tool
AI and machine learning utilities for .NET applications.
FonsecaFramework.Ai is a .NET 9 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.
dotnet add package FonsecaFramework.Ai
| 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 |
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");
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}");
using FonsecaFramework.Ai;
// Build from a folder of .txt documents
var store = await RagVectorStore.Build(
sourceFolder: "./docs",
chunkSize: 512,
chunkOverlap: 128);
// Augment a user prompt with relevant context
string augmentedPrompt = await store.Lookup(
prompt: "How do I configure the database?",
topK: 3);
Console.WriteLine(augmentedPrompt);
// The prompt now includes the most relevant document chunks as context
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);
// Filter by discourse category
string result = await store.Lookup(
prompt: "What safety precautions should I take?",
topK: 5,
sentimentFilter: "cautionary");
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);
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"
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);
OllamaSentimentAnalyzer / VLRChatClient: an OpenAI-compatible LLM endpoint (e.g. Ollama)Copyright 2025 Steven Fonseca / VLR Creations
Licensed under the . You may use this library free of charge, provided you include the required attribution notices. See the file for full terms.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on FonsecaFramework.Ai:
| Package | Downloads |
|---|---|
|
FonsecaFramework.Asp
Base Classes for Asp.Net Core |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.6.18.1 | 0 | 6/18/2026 |
| 2026.6.13.1 | 81 | 6/13/2026 |
| 2026.6.4.2 | 135 | 6/4/2026 |
| 2026.6.4.1 | 127 | 6/4/2026 |
| 2026.6.3.3 | 137 | 6/4/2026 |
| 2026.6.3.2 | 138 | 6/4/2026 |
| 2026.6.3.1 | 135 | 6/3/2026 |
| 2026.5.21.1 | 135 | 5/22/2026 |
| 2026.5.20.1 | 140 | 5/20/2026 |
| 2026.5.12.1 | 142 | 5/13/2026 |
| 2026.5.11.1 | 144 | 5/11/2026 |
| 2026.5.7.2 | 142 | 5/7/2026 |
| 2026.5.7.1 | 135 | 5/7/2026 |
| 2026.5.6.1 | 121 | 5/6/2026 |
| 2026.5.5.1 | 122 | 5/5/2026 |
| 2026.5.2.1 | 123 | 5/2/2026 |
| 2026.4.30.1 | 115 | 4/30/2026 |
| 2026.4.29.1 | 148 | 4/29/2026 |
| 2026.4.27.1 | 128 | 4/28/2026 |
| 2026.4.22.1 | 115 | 4/22/2026 |