Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.
MentorCard record
The MentorCard record of Novior.MentorAgent.Abstractions.Models: A structured card rendered in the chat instead of being described in prose — Level 2 of…
On this page
A structured card rendered in the chat instead of being described in prose — Level 2 of generative UI (roadmap #14). Level 1 is Markdown tables and lists; this is real UI with fields, an accent and buttons the user can press.
A card is built by your tool, never by the model. An [MentorAction] method returns a MentorCard (or several) and MentorAgent renders it; the model only decides when to call that tool. This is what makes cards safe to give buttons: every label, URL and action name is written by your code, so a prompt injection cannot make the assistant render a link to somewhere you never approved. It also means a card cannot hallucinate a field.
[MentorAction("get_order", "Shows an order")]
public MentorCard GetOrder(int id)
{
var o = _db.Orders.Find(id);
return new MentorCard("order")
{
Title = $"Order #{o.Id}",
Subtitle = o.CustomerName,
Accent = o.Status == "Shipped" ? MentorCardAccent.Success : MentorCardAccent.Warning,
Fields = [ new("Total", o.Total.ToString("C")), new("Status", o.Status) ],
Actions = [ new("Open", MentorCardActionKind.Navigate, $"/orders/{o.Id}") ],
};
}Definition
Section titled “Definition”Namespace: Novior.MentorAgent.Abstractions.Models. Package: Novior.MentorAgent.Abstractions.
public sealed record MentorCard : IEquatable<MentorCard>
dotnet add package Novior.MentorAgent.AbstractionsConstructors
Section titled “Constructors”public MentorCard(string Kind)
A structured card rendered in the chat instead of being described in prose — Level 2 of generative UI (roadmap #14). Level 1 is Markdown tables and lists; this is real UI with fields, an accent and buttons the user can press.
A card is built by your tool, never by the model. An [MentorAction] method returns a MentorCard (or several) and MentorAgent renders it; the model only decides when to call that tool. This is what makes cards safe to give buttons: every label, URL and action name is written by your code, so a prompt injection cannot make the assistant render a link to somewhere you never approved. It also means a card cannot hallucinate a field.
[MentorAction("get_order", "Shows an order")]
public MentorCard GetOrder(int id)
{
var o = _db.Orders.Find(id);
return new MentorCard("order")
{
Title = $"Order #{o.Id}",
Subtitle = o.CustomerName,
Accent = o.Status == "Shipped" ? MentorCardAccent.Success : MentorCardAccent.Warning,
Fields = [ new("Total", o.Total.ToString("C")), new("Status", o.Status) ],
Actions = [ new("Open", MentorCardActionKind.Navigate, $"/orders/{o.Id}") ],
};
}Parameters
Kind: Your own name for this card type —"order","product". The built-in renderer ignores it; a host that supplies a custom template uses it to choose one. Keep it stable, it is effectively the card's contract with the UI.
Properties
Section titled “Properties”Accent
Section titled “Accent”public MentorCardAccent Accent { get; init; }
Colour accent conveying state at a glance.
Actions
Section titled “Actions”public IReadOnlyList<MentorCardAction>? Actions { get; init; }
Buttons. Keep it to two or three — a card is a summary, not a form.
Fields
Section titled “Fields”public IReadOnlyList<MentorCardField>? Fields { get; init; }
Label/value rows, in display order.
ImageUrl
Section titled “ImageUrl”public string? ImageUrl { get; init; }
Optional image (absolute URL or data: URI).
public string Kind { get; init; }
Your own name for this card type — "order", "product". The built-in renderer ignores it; a host that supplies a custom template uses it to choose one. Keep it stable, it is effectively the card's contract with the UI.
Subtitle
Section titled “Subtitle”public string? Subtitle { get; init; }
Secondary line under the title.
public string? Title { get; init; }
Heading. Rendered as text — never as markup.
