32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import { shouldUseScheduleAssistant } from '../../schedule-intent.mjs';
|
|
|
|
const INTENT_RULES = [
|
|
{ task: 'translate', pattern: /翻译|译成|translate/i },
|
|
{ task: 'summary', pattern: /总结|概括|摘要|提炼|归纳/ },
|
|
{ task: 'rewrite', pattern: /改写|润色|优化文|帮我写|写一[篇封份个]/ },
|
|
{ task: 'poster', pattern: /海报|宣传图|banner/i },
|
|
{ task: 'ppt', pattern: /ppt|PPT|幻灯片/ },
|
|
{ task: 'mindmap', pattern: /思维导图|脑图/ },
|
|
{ task: 'code', pattern: /代码|写个函数|写个方法|debug|报错|bug/i },
|
|
{ task: 'search', pattern: /查一下|搜索|帮我找|查找/ },
|
|
];
|
|
|
|
export function resolveIntent(msgType, text) {
|
|
if (msgType === 'image') return { task: 'image_analysis' };
|
|
if (msgType === 'file') return { task: 'file_analysis' };
|
|
if (msgType === 'voice') return { task: 'voice_analysis' };
|
|
if (msgType === 'location') return { task: 'location' };
|
|
if (msgType === 'link') return { task: 'link' };
|
|
|
|
const t = String(text ?? '').trim();
|
|
if (!t) return { task: 'unknown' };
|
|
|
|
if (shouldUseScheduleAssistant(t)) return { task: 'schedule' };
|
|
|
|
for (const rule of INTENT_RULES) {
|
|
if (rule.pattern.test(t)) return { task: rule.task };
|
|
}
|
|
|
|
return { task: 'unknown' };
|
|
}
|