feat(wechat): add admin-pluggable LLM intent router separate from H5.
Memind CI / Test, build, and release guards (push) Failing after 8s
Memind CI / Test, build, and release guards (push) Failing after 8s
Give WeChat MP its own chat.general→page.generate LLM refinement layer with memindadm toggles, shadow mode, and canary openids so service account routing stays independent of the H5 chatIntentRouter. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+23
-3
@@ -1487,6 +1487,7 @@ export function createWechatMpService({
|
||||
wechatScheduleLlmConfigService = null,
|
||||
llmProviderService = null,
|
||||
chatIntentRouter = null,
|
||||
wechatIntentRouter = null,
|
||||
systemDisclosurePolicyService = null,
|
||||
onPageGenerated = null,
|
||||
applySessionLlmProvider = null,
|
||||
@@ -2433,7 +2434,7 @@ export function createWechatMpService({
|
||||
};
|
||||
|
||||
const runIntentMessage = async ({ inbound, intent, user }) => {
|
||||
const wechatIntent = await resolveWechatIntent(intent);
|
||||
const wechatIntent = await resolveWechatIntent(intent, { openid: inbound.fromUserName });
|
||||
const mediaAnalysisEnabled = isWechatMediaGrayUser(user, config.mediaAnalysisGrayUsers);
|
||||
const reliabilityEnabled = isWechatMediaGrayUser(user, config.reliabilityGrayUsers);
|
||||
const agentReplyTimeoutMs = reliabilityEnabled ? config.agentReplyTimeoutMs : 0;
|
||||
@@ -3066,7 +3067,7 @@ export function createWechatMpService({
|
||||
}
|
||||
};
|
||||
|
||||
const resolveWechatIntent = async (intent) => {
|
||||
const resolveWechatIntent = async (intent, { openid = null } = {}) => {
|
||||
const wechatIntent = classifyWechatIntent(intent);
|
||||
if (intent.msgType !== 'text' && intent.msgType !== 'voice') return wechatIntent;
|
||||
const sessionActionResult = await resolveWechatSessionAction(intent.agentText, {
|
||||
@@ -3080,7 +3081,26 @@ export function createWechatMpService({
|
||||
if (sessionActionResult.action === 'ignore_previous') {
|
||||
intent.sessionAction = sessionActionResult.action;
|
||||
}
|
||||
return { ...wechatIntent, sessionActionResult };
|
||||
const withSession = {
|
||||
...wechatIntent,
|
||||
sessionActionResult,
|
||||
};
|
||||
if (!wechatIntentRouter?.refineIntent) {
|
||||
return withSession;
|
||||
}
|
||||
try {
|
||||
return await wechatIntentRouter.refineIntent({
|
||||
ruleIntent: withSession,
|
||||
text: intent.agentText,
|
||||
openid,
|
||||
});
|
||||
} catch (err) {
|
||||
logger.warn?.(
|
||||
'WeChat MP intent router refine skipped:',
|
||||
err instanceof Error ? err.message : err,
|
||||
);
|
||||
return withSession;
|
||||
}
|
||||
};
|
||||
|
||||
const handleInboundMessage = async (bodyText, query = {}) => {
|
||||
|
||||
Reference in New Issue
Block a user