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,6 +366,8 @@ 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'])));
|
||||
// 第二轮开始注入system prompt
|
||||
if (messages.length > 2) {
|
||||
if (hasFileOrImage) {
|
||||
let newFileMessage = {
|
||||
"content": "关注用户最新发送文件和消息",
|
||||
@ -373,7 +375,7 @@ function messagesPrepare(messages: any[]) {
|
||||
};
|
||||
messages.splice(messages.length - 1, 0, newFileMessage);
|
||||
logger.info("注入提升尾部文件注意力system prompt");
|
||||
} else if (messages.length > 2) {
|
||||
} else {
|
||||
let newTextMessage = {
|
||||
"content": "关注用户最新的消息",
|
||||
"role": "system"
|
||||
@ -381,6 +383,7 @@ function messagesPrepare(messages: any[]) {
|
||||
messages.splice(messages.length - 1, 0, newTextMessage);
|
||||
logger.info("注入提升尾部消息注意力system prompt");
|
||||
}
|
||||
}
|
||||
|
||||
const content = messages.reduce((content, message) => {
|
||||
if (Array.isArray(message.content)) {
|
||||
|
Loading…
Reference in New Issue
Block a user