mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: update prompt
This commit is contained in:
parent
09753d2a82
commit
660de1b462
2 changed files with 11 additions and 9 deletions
|
|
@ -45,9 +45,6 @@ export class MemoryManager extends plugin {
|
||||||
dsc: '处理记忆系统相关的采集与管理',
|
dsc: '处理记忆系统相关的采集与管理',
|
||||||
event: 'message',
|
event: 'message',
|
||||||
priority: 550,
|
priority: 550,
|
||||||
task: [
|
|
||||||
|
|
||||||
],
|
|
||||||
rule: [
|
rule: [
|
||||||
// {
|
// {
|
||||||
// reg: '[\\s\\S]+',
|
// reg: '[\\s\\S]+',
|
||||||
|
|
@ -78,13 +75,15 @@ export class MemoryManager extends plugin {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
collector.tickHistoryPolling(true).catch(err => logger.error('Failed to trigger initial group history poll:', err))
|
// 兼容miao和trss,气死了
|
||||||
this.task.push({
|
let task = {
|
||||||
name: 'ChatGPT-群记忆轮询',
|
name: 'ChatGPT-群记忆轮询',
|
||||||
cron: '*/1 * * * *',
|
cron: '*/1 * * * *',
|
||||||
fnc: this.pollHistoryTask.bind(this),
|
fnc: this.pollHistoryTask.bind(this),
|
||||||
log: false
|
log: false
|
||||||
})
|
}
|
||||||
|
this.task = [task]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async collect (e) {
|
async collect (e) {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,11 @@ function parseJSON (text) {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
const trimmed = text.trim()
|
||||||
|
const codeBlockMatch = trimmed.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i)
|
||||||
|
const payload = codeBlockMatch ? codeBlockMatch[1] : trimmed
|
||||||
try {
|
try {
|
||||||
return JSON.parse(text)
|
return JSON.parse(payload)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn('Failed to parse JSON from memory extractor response:', text)
|
logger.warn('Failed to parse JSON from memory extractor response:', text)
|
||||||
return null
|
return null
|
||||||
|
|
@ -77,7 +80,7 @@ function buildExistingMemorySection (existingMemories = []) {
|
||||||
function buildUserSystemPrompt (existingMemories = []) {
|
function buildUserSystemPrompt (existingMemories = []) {
|
||||||
return `You are an assistant that extracts long-term personal preferences or persona details about a user.
|
return `You are an assistant that extracts long-term personal preferences or persona details about a user.
|
||||||
Given a conversation snippet between the user and the bot, identify durable information such as preferences, nicknames, roles, speaking style, habits, or other facts that remain valid over time.
|
Given a conversation snippet between the user and the bot, identify durable information such as preferences, nicknames, roles, speaking style, habits, or other facts that remain valid over time.
|
||||||
Return a JSON array of **strings**, and nothing else. Each string must be a short sentence (in the same language as the conversation) describing one piece of long-term memory. Do not include keys, JSON objects, or additional metadata. Ignore temporary topics or uncertain information.
|
Return a JSON array of **strings**, and nothing else. The full response must be a json array!!! Each string must be a short sentence (in the same language as the conversation) describing one piece of long-term memory. Do not include embedded JSON objects, or additional metadata. Ignore temporary topics or uncertain information.
|
||||||
|
|
||||||
${buildExistingMemorySection(existingMemories)}`
|
${buildExistingMemorySection(existingMemories)}`
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +107,7 @@ async function callModel ({ prompt, systemPrompt, model, maxToken = 4096, temper
|
||||||
]
|
]
|
||||||
}, SendMessageOption.create({
|
}, SendMessageOption.create({
|
||||||
model,
|
model,
|
||||||
temperature,
|
// temperature,
|
||||||
maxToken,
|
maxToken,
|
||||||
systemOverride: systemPrompt,
|
systemOverride: systemPrompt,
|
||||||
disableHistoryRead: true,
|
disableHistoryRead: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue