AI Chat Assistant
The AI Chat Assistant allows users to interact with an AI assistant in real-time to receive intelligent suggestions and help during the document editing process.
Effect Screenshot
Features and Advantages
- Support for private deployment, allowing you to ensure data security and controllability through private deployment;
- More user-friendly operation experience and non-intrusive chat tool design compared to AI document assistants;
- Support for multi-turn conversations, enabling you to obtain more accurate intelligent suggestions through extended dialogues;
- Support for customizing multiple AI models, allowing you to switch between and use custom AI models;
- Support for inference mode, enabling you to configure and display inference mode for AI models that support it;
- Support for message history, allowing you to view historical messages in the chat record for message viewing and management;
- Support for file uploads, enabling you to configure file uploads to provide AI models with richer contextual information.
Default Configuration
const systemPrompt = `**角色定位**
你是一个专业文档 AI 助手,具备以下核心能力:
1. 精准解析用户碎片化需求
2. 上下文敏感的内容整合
3. 多维度文档质量把控
4. Markdown语法专家级应用
**任务说明**
当前用户正在富文本编辑器(基于 Tiptap 和 ProseMirror 开发)中进行文档创作,你需要完成以下协同工作流程:
**输入分析阶段**
1. 深度理解用户提供的上下文片段:{context}
2. 通读当前完整文档:
\`\`\`html
{document}
\`\`\`
3. 确认目标语言要求:{lang}(需确保语法地道性)
4. 识别用户未明示的潜在需求:
- 格式一致性检查
- 逻辑连贯性增强
- 术语统一性维护
**输出规范**
请按以下标准生成内容:
▢ 格式标准:
- 严格使用基础Markdown语法,但不能将内容整个返回成代码块
- 标题层级不超过###
- 列表项采用标准符号
- 代码块标注语言类型
▢ 内容标准:
- 保持与现有文档风格统一
- 新增内容自然衔接上下文
- 重要信息优先呈现原则
- 技术文档需保持术语准确
**异常处理机制**
当遇到以下情况时:
1. 需求存在歧义
2. 上下文信息不足
3. 发现文档内在矛盾
请主动询问澄清:
"为确保输出质量,需要您确认以下细节:[具体问题] 请提供补充说明/示例/偏好要求"
**执行示例**
[用户需求] "在第三章添加数据可视化注意事项"
[AI响应]
1. 定位第三章现有内容
2. 分析文档中已有的图表规范
3. 生成符合整体风格的注意事项列表
4. 使用与前后文匹配的过渡语句
只需要返回结果,不要将结果放在代码块中,无需其他任何额外说明,除非用户要求,返回内容尽量不要太过复杂。
`
const welcomeMessage =
'欢迎使用 Umo Editor AI 聊天助手!有什么问题可以问我哦,我会尽力帮助您完成文档编辑工作。'
// AI Chat Assistant-related configuration
const defaultOptions = {
ai: {
chat: {
enabled: false,
layout: 'both',
showName: true,
showDatetime: true,
showAvatar: true,
commands: [
{
label: { en_US: 'Continuation', zh_CN: '续写', ru_RU: 'Продолжение' },
value: { en_US: 'Continuation', zh_CN: '续写', ru_RU: 'Продолжение' },
},
{
label: { en_US: 'Rewrite', zh_CN: '重写', ru_RU: 'Переписать' },
value: { en_US: 'Rewrite', zh_CN: '重写', ru_RU: 'Переписать' },
},
{
label: { en_US: 'Abbreviation', zh_CN: '缩写', ru_RU: 'Аббревиатура' },
value: { en_US: 'Abbreviation', zh_CN: '缩写', ru_RU: 'Аббревиатура' },
},
{
label: { en_US: 'Expansion', zh_CN: '扩写', ru_RU: 'Расширение' },
value: { en_US: 'Expansion', zh_CN: '扩写', ru_RU: 'Расширение' },
},
{
label: { en_US: 'Polish', zh_CN: '润色', ru_RU: 'Полировать' },
value: { en_US: 'Polish', zh_CN: '润色', ru_RU: 'Полировать' },
},
{
label: { en_US: 'Proofread', zh_CN: '校阅', ru_RU: 'Корректура' },
value: { en_US: 'Proofread', zh_CN: '校阅', ru_RU: 'Корректура' },
},
{
label: { en_US: 'Translate', zh_CN: '翻译', ru_RU: 'Перевести' },
value: {
en_US: 'Translate to chinese',
zh_CN: '翻译成英文',
ru_RU: 'Перевести на китайский',
},
},
],
models: [],
systemPrompt,
welcomeMessage,
maxHistory: 10,
async onGetHistory() {
},
async onChangeHistory(type, data) {
}
},
}
Configuration Description
ai.chat
AI Chat Assistant configuration. For more details, see AI Document Assistant.
ai.chat.enabled
: Boolean – whether to enable the AI assistant.ai.chat.layout
: String – the message layout mode of the AI Document Assistant. Supportsboth
andsingle
, default isboth
.ai.chat.showName
: Boolean – whether to display the message name. Default istrue
.ai.chat.showDatetime
: Boolean – whether to display the message timestamp. Default istrue
.ai.chat.showAvatar
: Boolean – whether to display the avatar. Default istrue
.ai.chat.commands
: Array – commonly used commands. See AI Document Assistant Configuration.ai.chat.systemPrompt
: String – the system prompt to help the AI better understand its role and tasks.ai.chat.welcomeMessage
: String – welcome message shown when the AI Chat Assistant is opened. If empty, no message is displayed.ai.chat.maxHistory
: Number – maximum number of historical messages.ai.chat.onGetHistory
: AsyncFunction – callback for fetching historical messages, can be used to retrieve them from the server.ai.chat.onChangeHistory
: AsyncFunction – callback for updating historical messages on the server (e.g., delete, add).ai.chat.models
: Array – configuration of AI models. Supports multiple models; at least one should be configured. See below for options.
Option | Type | Description |
---|---|---|
isDefault | Boolean | Whether it is the default model |
label | String | Model name shown in the message list |
value | String | Model identifier sent to the backend |
avatar | URL | URL of the model avatar shown in the message list |
provider | URL | AI service provider endpoint for the model |
supportReason | Boolean | Whether the model supports reasoning mode |
file | Object | Upload file configuration; supports accept , multiple , maxSize , limit , etc. |
Example:
[
// DeepSeek
{
label: 'DeepSeek-R1',
value: 'deepseek-reasoner',
avatar: '...',
isDefault: true,
// In this example, Umo Editor Server proxies AI requests to other providers, but you can customize the provider
provider: 'http://127.0.0.1:1235/ai/deepseek/chat%2Fcompletions',
supportReason: true,
file: {
accept: '.docx,.doc,.xls,.xlsx,.txt', // Supported file types
multiple: true, // Allow multiple file selection
maxSize: 1024 * 1024 * 5, // Max size per file
limit: 5, // Maximum number of files
},
},
// Moonshot AI
{
label: 'Moonshot AI',
value: 'moonshot-v1-8k',
avatar: kimiLogo,
provider: 'http://127.0.0.1:1235/ai/moonshot/chat%2Fcompletions',
},
]
Method List
openAIChat
Description: Open the AI Chat Assistant.
Parameters: None
Return: None
closeAIChat
Description: Close the AI Chat Assistant.
Parameters: None
Return: None