Polhem.Chat.Avalonia 0.2.1

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

Polhem.Chat.Avalonia

An AI chat control for Avalonia on top of any Microsoft.Extensions.AI IChatClient: streamed replies rendered as Markdown with Polhem.Markdown.Avalonia, reasoning, tool calls, per-turn usage, stop and copy. The conversation model is in Polhem.Chat.

Getting started

The control needs Avalonia 12 or later. Add the theme after your base theme (Fluent, Semi or another):

<Application.Styles>
  <FluentTheme />
  <chat:ChatTheme />
</Application.Styles>

with xmlns:chat="using:Polhem.Chat.Avalonia". Then put a ChatView in a window and give it a runner for your client:

<chat:ChatView x:Name="Chat" />
Chat.Runner = new ChatRunner(chatClient);

Enter sends, Shift+Enter starts a new line, and Esc or the stop button stops the reply.

Running your own loop

An application with its own tool loop sets Conversation instead of Runner, handles PromptSubmitted and StopRequested, and sets IsGenerating while it streams into the conversation with ChatConversation.BeginTurn. Calling ChatTurn.BeginCall before each request to the model lets the progress line and the turn summary show how many requests the turn took.

The activity line

While a reply is in progress, one line under the conversation shows an animated icon, what the model is doing, the running time, the request it is on and the output tokens so far. The reasoning and the tool calls do not show as entries unless ShowsActivity is set, or the user opens them with the › at the end of the line. ActivityIcon takes an avares:// URI of another animated GIF.

Images and CJK text in replies

A reply is the model's text, so it is not trusted. A prompt injection can have the model write an image whose address carries data from the conversation, and loading the image would send that data to the image's server. Replies therefore show no images: each shows its alternative text, written in Markdown or as an HTML img.

This holds for the package's reply template. A template of your own for AssistantReplyEntry uses its own MarkdownViewer, which loads https images unless you give it options. Set them as a value, not through a binding to the view, because the viewer renders as soon as its text arrives, before such a binding resolves.

To show images, set MarkdownOptions to options of your own. A new MarkdownOptions allows images over https; change AllowedImageSchemes before assigning it, and assign a new instance to change it later:

var options = new MarkdownOptions();          // Polhem.Markdown
Chat.MarkdownOptions = options;               // replies now load https images

The same options decide which links can be clicked and how relative links resolve.

Bold Chinese or Japanese text can draw regular through the fallback fonts. Set CjkFontFamily to the family for the language your users read, for example PingFang TC, Microsoft JhengHei UI, Noto Sans CJK TC for Traditional Chinese.

Templates, texts and colors

  • Each entry type has a default template. Add a DataTemplate to the view's DataTemplates, or to any ancestor's, to show an entry type of your own or to replace a default.
  • The texts ship in English and Traditional Chinese. Assign ChatViewStrings.ForCulture(culture), changed as you like, to Strings.
  • The colors are brushes in the theme's resources (see ChatTheme); declare the same key in your resources to change one.

The packages are at 0.x: a minor version may still change the API. See the repository.

Product 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. 
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
0.2.1 0 11/25/2026
0.2.0 0 11/25/2026
0.1.2 12 11/24/2026
0.1.1 51 11/24/2026
0.1.0 49 11/24/2026