SuncodeSoftware.SuperSDK.Talk 4.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SuncodeSoftware.SuperSDK.Talk --version 4.1.0
                    
NuGet\Install-Package SuncodeSoftware.SuperSDK.Talk -Version 4.1.0
                    
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="SuncodeSoftware.SuperSDK.Talk" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuncodeSoftware.SuperSDK.Talk" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SuncodeSoftware.SuperSDK.Talk" />
                    
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 SuncodeSoftware.SuperSDK.Talk --version 4.1.0
                    
#r "nuget: SuncodeSoftware.SuperSDK.Talk, 4.1.0"
                    
#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 SuncodeSoftware.SuperSDK.Talk@4.1.0
                    
#: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=SuncodeSoftware.SuperSDK.Talk&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SuncodeSoftware.SuperSDK.Talk&version=4.1.0
                    
Install as a Cake Tool

SuperSDK.Talk

SuperSDK AI 对话组件库,提供开箱即用的聊天消息体系,原生集成 SuperSDK MessageBus。

功能

  • 可扩展消息模型:抽象基类 + 内置 Text / Image / PDF / System 四种类型
  • ChatBox 控件:Avalonia 控件,自动订阅 MessageBus,自动渲染消息
  • 渲染注册表:新增消息类型只需新增一个渲染器类,无需修改现有代码
  • 引用/回复:内置气泡引用展示,支持跨类型引用
  • 软删除:删除后显示占位符,不影响引用链
  • 状态显示:Pending / Sent / Delivered / Read / Failed 五级状态图标
  • 混淆 + 签名保护:DLL 完整性验证,防止篡改

安装

dotnet add package SuncodeSoftware.SuperSDK.Talk

快速开始

using SuperSDK.Talk.Controls;
using SuperSDK.Talk.Messages;

// 1. 创建控件并放入界面
var chatBox = new ChatBox();

// 2. 订阅 MessageBus(任意通道均可)
chatBox.SubscribeGlobal();
// 或: chatBox.SubscribeFixture(0);
// 或: chatBox.SubscribeSlot(0, 1);

// 3. 发布消息(由 AI 响应模块或其他地方调用)
MessageBus.Pub(new ChatMessageReceived {
    Message = TextChatMessage.Inbound("ai", "Assistant", "你好,有什么可以帮你的?")
});

// 4. 直接推送(不走 MessageBus)
chatBox.PostMessage(TextChatMessage.Outbound("user", "我", "帮我解释一下 GPT"));

消息类型一览

类型 ContentType 说明
TextChatMessage text 纯文本,支持多行
ImageChatMessage image 图片(含缩略图预览)
PdfChatMessage pdf PDF 文件(含首页缩略图)
SystemChatMessage system 系统通知(居中,无气泡)

扩展新消息类型

// 1. 定义消息模型
public class AudioChatMessage : ChatMessage {
    public string AudioPath { get; set; } = "";
    public TimeSpan Duration { get; set; }
    public override string ContentType => "audio";
    public override string GetPreviewText() => $"[语音] {Duration:mm\\:ss}";
}

// 2. 定义 ViewModel
public class AudioChatMessageViewModel : ChatMessageViewModel {
    public AudioChatMessageViewModel(AudioChatMessage m) : base(m) { ... }
    public override string ContentType => "audio";
    protected override void ExecuteCopy() { ... }
}

// 3. 定义渲染器(继承 ChatMessageCellRendererBase)
public class AudioMessageCellRenderer : ChatMessageCellRendererBase {
    public override string ContentType => "audio";
    protected override Control BuildContentArea(ChatMessageViewModel vm) {
        // 只需构建内容区,基类负责引用气泡、删除状态、时间戳等
        var audioVm = (AudioChatMessageViewModel)vm;
        return new Button { Content = $"▶  {audioVm.DurationText}" };
    }
}

// 4. 注册(程序启动时执行一次)
ChatMessageViewModelFactory.Register("audio", m => new AudioChatMessageViewModel((AudioChatMessage)m));
chatBox.RendererRegistry.Register(new AudioMessageCellRenderer());

架构层次

Messages/           ← 纯数据模型(无 UI 依赖)
  ChatMessage       ← 抽象基类:Id、时间、发送方、方向、状态、删除、引用
  TextChatMessage   ← 文本内容
  ImageChatMessage  ← 图片(路径、格式、缩略图)
  PdfChatMessage    ← PDF(路径、页数、缩略图)
  SystemChatMessage ← 系统通知

ViewModels/         ← ReactiveUI ViewModel(大量逻辑在基类)
  ChatMessageViewModel     ← 抽象基类:时间格式化、引用状态、删除命令、状态图标
  TextChatMessageViewModel
  ImageChatMessageViewModel ← 懒加载 Bitmap、OpenOriginal
  PdfChatMessageViewModel   ← 懒加载缩略图、OpenPdf
  ChatBoxViewModel          ← 集合管理 + MessageBus 订阅

Renderers/          ← 渲染器(Template Method 模式)
  IChatMessageCellRenderer       ← 接口
  ChatMessageCellRendererBase    ← 抽象基类:公共布局(头、引用、状态行、删除层)
  TextMessageCellRenderer        ← 只实现内容区
  ImageMessageCellRenderer       ← 只实现内容区
  PdfMessageCellRenderer         ← 只实现内容区
  ChatCellRendererRegistry       ← 注册表,支持运行时扩展

Controls/
  ChatBox            ← Avalonia UserControl,集成 ViewModel + Registry
Product 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. 
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
5.0.0 32 3/13/2026
4.8.0 36 3/12/2026
4.7.0 33 3/12/2026
4.6.0 30 3/12/2026
4.5.0 28 3/12/2026
4.4.0 32 3/12/2026
4.3.0 31 3/12/2026
4.1.0 76 3/9/2026

add talk ui