mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2024-11-01 20:09:20 +08:00
首轮不注入注意力prompt
This commit is contained in:
parent
f5bea5ea68
commit
9fd7ae890b
@ -366,20 +366,23 @@ function messagesPrepare(messages: any[]) {
|
||||
let latestMessage = messages[messages.length - 1];
|
||||
let hasFileOrImage = Array.isArray(latestMessage.content)
|
||||
&& latestMessage.content.some(v => (typeof v === 'object' && ['file', 'image_url'].includes(v['type'])));
|
||||
if (hasFileOrImage) {
|
||||
let newFileMessage = {
|
||||
"content": "关注用户最新发送文件和消息",
|
||||
"role": "system"
|
||||
};
|
||||
messages.splice(messages.length - 1, 0, newFileMessage);
|
||||
logger.info("注入提升尾部文件注意力system prompt");
|
||||
} else if (messages.length > 2) {
|
||||
let newTextMessage = {
|
||||
"content": "关注用户最新的消息",
|
||||
"role": "system"
|
||||
};
|
||||
messages.splice(messages.length - 1, 0, newTextMessage);
|
||||
logger.info("注入提升尾部消息注意力system prompt");
|
||||
// 第二轮开始注入system prompt
|
||||
if (messages.length > 2) {
|
||||
if (hasFileOrImage) {
|
||||
let newFileMessage = {
|
||||
"content": "关注用户最新发送文件和消息",
|
||||
"role": "system"
|
||||
};
|
||||
messages.splice(messages.length - 1, 0, newFileMessage);
|
||||
logger.info("注入提升尾部文件注意力system prompt");
|
||||
} else {
|
||||
let newTextMessage = {
|
||||
"content": "关注用户最新的消息",
|
||||
"role": "system"
|
||||
};
|
||||
messages.splice(messages.length - 1, 0, newTextMessage);
|
||||
logger.info("注入提升尾部消息注意力system prompt");
|
||||
}
|
||||
}
|
||||
|
||||
const content = messages.reduce((content, message) => {
|
||||
|
Loading…
Reference in New Issue
Block a user