Core Docs

AIChat / ChatV2 / ChatV3

Widget chat AI — cho user trò chuyện với LLM, parse phản hồi qua event `AfterChat`.

Source: Core/Components/AIChat.cs, ChatV2.cs, ChatV3.cs · ComType: AIChat, ChatV2, ChatV3

Cấu hình

ComType:    AIChat
Label:      Trợ lý ảo
Style:      "height: 500px"

Field DB dùng

FieldVai trò
Label(AIChat) Tiêu đề widget chat hiển thị trên header.
Style(AIChat) Inline CSS cho container chat (vd "height: 500px").
EventsJSON map {"AfterChat": "OnChatResponse"} để hook handler khi AI trả lời.
IsRealtime(ChatV3) True → push message qua WebSocket realtime giữa các session.
UpperCase(ChatV3) True → uppercase reply text.
ComponentField hỗ trợ
AIChatEvents, Label, Style
ChatV2Events
ChatV3Events, IsRealtime, UpperCase

Events kích hoạt

EventMethod signature
AfterChat(taskComment, result, timeLine)

Fire sau khi AI trả lời xong. result là text response, taskComment là user message, timeLine là history.

public void OnChatResponse(object taskComment, object result, object timeLine)
{
    var answer = result?.ToString();
    Toast.Small("AI: " + answer);
}

Khác biệt giữa các version

  • AIChat — phiên bản cơ bản với label tùy biến.
  • ChatV2 — version tiếp theo, đơn giản hoá API.
  • ChatV3 — version mới nhất, hỗ trợ realtime push (WebSocket) qua IsRealtime.

Dùng version cao nhất (ChatV3) cho project mới.

Tip

  • Pipeline AI cần wire bên backend (OpenAI / Anthropic / Azure OpenAI).
  • Style chỉnh kích cỡ widget chat (chiều cao container).

Core Docs · Astro · Core.API/wwwRoot/docs