mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-05-30 07:36:45 +00:00
feat: Add AI User Persona
This commit is contained in:
@@ -32,6 +32,7 @@ import { httpService } from './services/httpService'
|
||||
import { messagePushService } from './services/messagePushService'
|
||||
import { insightService } from './services/insightService'
|
||||
import { insightRecordService } from './services/insightRecordService'
|
||||
import { insightProfileService } from './services/insightProfileService'
|
||||
import { groupSummaryService } from './services/groupSummaryService'
|
||||
import { normalizeWeiboCookieInput, weiboService } from './services/social/weiboService'
|
||||
import { bizService } from './services/bizService'
|
||||
@@ -1829,6 +1830,22 @@ function registerIpcHandlers() {
|
||||
return insightService.triggerSessionInsight(payload)
|
||||
})
|
||||
|
||||
ipcMain.handle('insight:listProfileStatuses', async (_, sessionIds: string[]) => {
|
||||
return insightProfileService.listProfileStatuses(Array.isArray(sessionIds) ? sessionIds : [])
|
||||
})
|
||||
|
||||
ipcMain.handle('insight:generateProfile', async (_, payload: {
|
||||
sessionId: string
|
||||
displayName?: string
|
||||
avatarUrl?: string
|
||||
}) => {
|
||||
return insightProfileService.generateProfile(payload)
|
||||
})
|
||||
|
||||
ipcMain.handle('insight:cancelProfile', async (_, sessionId?: string) => {
|
||||
return insightProfileService.cancelProfile(sessionId)
|
||||
})
|
||||
|
||||
ipcMain.handle('insight:generateFootprintInsight', async (_, payload: {
|
||||
rangeLabel: string
|
||||
summary: {
|
||||
|
||||
@@ -588,6 +588,13 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
displayName?: string
|
||||
avatarUrl?: string
|
||||
}) => ipcRenderer.invoke('insight:triggerSessionInsight', payload),
|
||||
listProfileStatuses: (sessionIds: string[]) => ipcRenderer.invoke('insight:listProfileStatuses', sessionIds),
|
||||
generateProfile: (payload: {
|
||||
sessionId: string
|
||||
displayName?: string
|
||||
avatarUrl?: string
|
||||
}) => ipcRenderer.invoke('insight:generateProfile', payload),
|
||||
cancelProfile: (sessionId?: string) => ipcRenderer.invoke('insight:cancelProfile', sessionId),
|
||||
generateFootprintInsight: (payload: {
|
||||
rangeLabel: string
|
||||
summary: {
|
||||
|
||||
1001
electron/services/insightProfileService.ts
Normal file
1001
electron/services/insightProfileService.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,7 @@ import { chatService, ChatSession, Message } from './chatService'
|
||||
import { snsService } from './snsService'
|
||||
import { weiboService } from './social/weiboService'
|
||||
import { showNotification } from '../windows/notificationWindow'
|
||||
import { insightProfileService } from './insightProfileService'
|
||||
import {
|
||||
insightRecordService,
|
||||
type InsightRecordLog,
|
||||
@@ -385,6 +386,7 @@ class InsightService {
|
||||
this.clearTimers()
|
||||
this.clearRuntimeCache()
|
||||
this.processing = false
|
||||
insightProfileService.cancelActiveTask('AI 见解服务已停止,画像任务已取消')
|
||||
if (hadActiveFlow) {
|
||||
insightLog('INFO', '已停止')
|
||||
}
|
||||
@@ -400,6 +402,7 @@ class InsightService {
|
||||
}
|
||||
|
||||
if (normalizedKey === 'dbPath' || normalizedKey === 'decryptKey' || normalizedKey === 'myWxid') {
|
||||
insightProfileService.cancelActiveTask('数据库或账号配置已变化,画像任务已取消')
|
||||
this.clearRuntimeCache()
|
||||
}
|
||||
|
||||
@@ -409,6 +412,7 @@ class InsightService {
|
||||
handleConfigCleared(): void {
|
||||
this.clearTimers()
|
||||
this.clearRuntimeCache()
|
||||
insightProfileService.cancelActiveTask('配置已清除,画像任务已取消')
|
||||
this.processing = false
|
||||
}
|
||||
|
||||
@@ -1467,6 +1471,7 @@ ${afterText}
|
||||
|
||||
const momentsContextSection = await this.getMomentsContextSection(sessionId)
|
||||
const socialContextSection = await this.getSocialContextSection(sessionId)
|
||||
const profileContextSection = insightProfileService.getProfileContextSection(sessionId)
|
||||
|
||||
// ── 默认 system prompt(稳定内容,有利于 provider 端 prompt cache 命中)────
|
||||
const DEFAULT_SYSTEM_PROMPT = `你是用户的私人关系观察助手,名叫"见解"。你的任务是主动提供有价值的观察和建议。
|
||||
@@ -1486,6 +1491,7 @@ ${afterText}
|
||||
? `已 ${silentDays} 天未联系「${resolvedDisplayName}」。`
|
||||
: '',
|
||||
contextSection,
|
||||
profileContextSection,
|
||||
momentsContextSection,
|
||||
socialContextSection,
|
||||
'请给出你的见解(≤80字):'
|
||||
|
||||
Reference in New Issue
Block a user