Giao diện
@digiforce-nc/plugin-ai
Plugin tích hợp AI vào hệ thống — kết nối LLM providers, tạo AI bots, quản lý tools/skills, hỗ trợ MCP clients, và tích hợp workflow.
Plugin này làm gì?
Plugin cung cấp nền tảng AI toàn diện: đăng ký nhiều LLM provider (OpenAI, Anthropic, Google, Ollama), tạo AI bots với personality và tools tùy chỉnh, kết nối MCP servers, và tích hợp vào workflow engine.
Bắt đầu nhanh (3 bước)
Mục tiêu của Digiforce là biến AI thành một năng lực có thể bật/tắt, phân quyền, và mở rộng giống như plugin.
- Bật AI: vào Settings → Plugin Manager và bật
plugin-ai. - Cấu hình LLM: vào Settings → AI → LLM Services và thêm ít nhất 1 provider/model.
- Tạo bot + gán năng lực: vào Settings → AI → Bots:
- Tạo bot (system prompt + model)
- Gán ít nhất 1 năng lực:
- Tools: làm việc có cấu trúc (tạo báo cáo, gọi API, tự động hoá)
- Skills (RAG): trả lời dựa trên tài liệu nội bộ (knowledge base)
- MCP: gọi tool từ hệ thống ngoài (nếu cần)
Bạn nên chọn “năng lực” nào?
- Cần câu trả lời dựa trên tài liệu nội bộ: dùng Knowledge base / RAG → xem
plugin-ai-knowledge-base. - Cần số liệu, thống kê theo collection: dùng Data Query (tool/skill truy vấn dữ liệu) → xem
plugin-data-source-manager. - Cần báo cáo có biểu đồ + markdown: dùng tool Business report (nếu bot được gán tool này).
AI trong Digiforce gồm những gì?
AI trong Digiforce không chỉ là “chat với LLM”, mà là một hệ gồm:
- Chat UI + Bots: trải nghiệm trò chuyện và vận hành bot theo role.
- Tools: các thao tác có schema/permission (AI “làm” được việc).
- Skills / Knowledge base (RAG): AI “biết” dựa trên dữ liệu/tài liệu thật.
- MCP: chuẩn kết nối tool từ hệ thống khác.
- Workflow: AI tham gia luồng tự động hoá (trigger + instruction).
Năm nhiệm vụ chính
| # | Nhiệm vụ | Chi tiết |
|---|---|---|
| 1 | LLM Provider Registry | Đăng ký, cấu hình nhiều LLM provider (API key, model, params) |
| 2 | AI Bots & Chat | Tạo bots với system prompt, gán tools/skills, chat conversations |
| 3 | MCP & Tools | Kết nối MCP servers, quản lý AI tools mở rộng |
| 4 | Web Search | Tìm kiếm web realtime qua sub-agent (hỗ trợ provider có khả năng web search) |
| 5 | Workflow | AI bot trigger + LLM instruction node trong workflow |
Kiến trúc
Luồng chat với AI bot
LLM Provider Registry & AIManager
AIManager class quản lý registry và khởi tạo provider instances:
typescript
class AIManager {
registerLLMProvider(name: string, meta: LLMProviderMeta): void;
listLLMProviders(): Array<{ name, title, supportedModel, supportWebSearch }>;
getSupportedProvider(model: SupportedModel): string[];
getLLMService(options: LLMModelOptions): Promise<{ provider, model, service }>;
}| Provider | Models | SDK | Web Search |
|---|---|---|---|
| OpenAI | GPT-4o, GPT-4, GPT-3.5 | @langchain/openai | - |
| Anthropic | Claude 3.5, Claude 3 | @langchain/anthropic | - |
| Gemini Pro, Gemini Flash | @langchain/google-genai | - | |
| DashScope | Qwen series | @langchain/community | Có |
| Ollama | Llama, Mistral, CodeLlama... | @langchain/ollama | - |
Mỗi provider khai báo supportWebSearch: boolean — cho phép AIManager chọn provider phù hợp khi bot cần tìm kiếm web.
Database - 12+ collections
| Collection | Chứa gì |
|---|---|
llmServices | Cấu hình LLM provider (API key, base URL, model) |
aiBots | Định nghĩa bot (system prompt, model, tools) |
aiConversations / aiMessages | Phiên chat và tin nhắn |
aiSettings | Cấu hình AI toàn cục |
aiSkills / aiContextDatasource | RAG skills, datasource connectors |
aiMcpClients / aiTools | MCP connections và tool definitions |
aiFiles | Files đính kèm trong chat |
lc-checkpoints | LangChain checkpoints (agent state) |
users-ai-bots | Liên kết user - bot (M2M) |
Vòng đời plugin
Web Search Tool
Plugin tích hợp sẵn tool subAgentWebSearch — cho phép AI bot tìm kiếm thông tin realtime từ internet:
Tool hỗ trợ tìm nhiều query song song, trả về kết quả có cấu trúc kèm nguồn tham chiếu. Yêu cầu provider đã đăng ký với supportWebSearch: true.
Workflow Integration
| Thành phần | Vai trò |
|---|---|
| AI Bot Trigger | Workflow kích hoạt khi user gửi message cho bot |
| LLM Instruction Node | Node gọi LLM với prompt tùy chỉnh, nhận kết quả |
Ví dụ sử dụng API
Cấu hình LLM provider
typescript
await agent.resource('llmServices').create({
values: {
name: 'openai-main',
provider: 'openai',
apiKey: 'sk-...',
defaultModel: 'gpt-4o',
},
});Tạo AI bot
typescript
await agent.resource('aiBots').create({
values: {
name: 'Support Bot',
systemPrompt: 'Bạn là trợ lý hỗ trợ khách hàng...',
llmServiceId: 1,
model: 'gpt-4o',
},
});Chat với bot
typescript
const conv = await agent.resource('aiConversations').create({
values: { botId: 1 },
});
await agent.resource('aiMessages').create({
values: {
conversationId: conv.body.data.id,
content: 'Làm sao để đặt hàng?',
role: 'user',
},
});Thành phần client
| Thành phần | Mô tả |
|---|---|
AIBotsProvider | Context provider cho AI bots state |
ChatInterface | Giao diện chat với AI bot |
LLMSettings | Trang cấu hình LLM providers |
MCPSettings | Trang cấu hình MCP clients |
BotManager | Trang quản lý AI bots |
WorkflowLLMNode | UI cho LLM node trong workflow editor |
ui-core/widgets/ | AI bot widgets tích hợp vào UiCore widget system (AIBotActionWidget, AIBotShortcutWidget...) |
Dependencies
| Package | Vai trò |
|---|---|
langchain, @langchain/openai, @langchain/anthropic, @langchain/google-genai, @langchain/ollama | LLM orchestration + providers |
zustand | State management cho chat UI |
react-markdown | Render markdown trong responses |