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
| Field | Vai trò |
|---|---|
Label | (AIChat) Tiêu đề widget chat hiển thị trên header. |
Style | (AIChat) Inline CSS cho container chat (vd "height: 500px"). |
Events | JSON 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. |
| Component | Field hỗ trợ |
|---|---|
AIChat | Events, Label, Style |
ChatV2 | Events |
ChatV3 | Events, IsRealtime, UpperCase |
Events kích hoạt
| Event | Method 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).
Stylechỉnh kích cỡ widget chat (chiều cao container).