Bỏ qua, đến nội dung

@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ốn nhiệm vụ chính

#Nhiệm vụChi tiết
1LLM Provider RegistryĐăng ký, cấu hình nhiều LLM provider (API key, model, params)
2AI Bots & ChatTạo bots với system prompt, gán tools/skills, chat conversations
3MCP & ToolsKết nối MCP servers, quản lý AI tools mở rộng
4WorkflowAI bot trigger + LLM instruction node trong workflow

Kiến trúc

Luồng chat với AI bot

LLM Provider Registry

ProviderModelsSDK
OpenAIGPT-4o, GPT-4, GPT-3.5@langchain/openai
AnthropicClaude 3.5, Claude 3@langchain/anthropic
GoogleGemini Pro, Gemini Flash@langchain/google-genai
OllamaLlama, Mistral, CodeLlama...@langchain/ollama

Database - 12+ collections

CollectionChứa gì
llmServicesCấu hình LLM provider (API key, base URL, model)
aiBotsĐịnh nghĩa bot (system prompt, model, tools)
aiConversations / aiMessagesPhiên chat và tin nhắn
aiSettingsCấu hình AI toàn cục
aiSkills / aiContextDatasourceRAG skills, datasource connectors
aiMcpClients / aiToolsMCP connections và tool definitions
aiFilesFiles đính kèm trong chat
lc-checkpointsLangChain checkpoints (agent state)
users-ai-botsLiên kết user - bot (M2M)

Vòng đời plugin

Workflow Integration

Thành phầnVai trò
AI Bot TriggerWorkflow kích hoạt khi user gửi message cho bot
LLM Instruction NodeNode 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ầnMô tả
AIBotsProviderContext provider cho AI bots state
ChatInterfaceGiao diện chat với AI bot
LLMSettingsTrang cấu hình LLM providers
MCPSettingsTrang cấu hình MCP clients
BotManagerTrang quản lý AI bots
WorkflowLLMNodeUI cho LLM node trong workflow editor

Dependencies

PackageVai trò
langchain, @langchain/openai, @langchain/anthropic, @langchain/google-genai, @langchain/ollamaLLM orchestration + providers
zustandState management cho chat UI
react-markdownRender markdown trong responses

Mục lục chi tiết