Compare commits

..

No commits in common. "d72db21461718b649fdca888644b272d59341bb5" and "fa0f3ceb4e0f6c03b6f88d5d663784a6e55ad392" have entirely different histories.

3 changed files with 6 additions and 11 deletions

View File

@ -89,10 +89,10 @@ async function index(e) {
return;
}
if (e.user_id === e.bot.uin) {
return e.reply(segment.image(await Meme.getMeme(aiConfig.character, 'default')));
return;
}
const userMessage = await extractUserMessage(e.msg, nickname, e);
if (!userMessage || userMessage.length === 0) {
if (!userMessage) {
return;
}
const adapter = await YunzaiUtils.getAdapter(e);
@ -130,9 +130,6 @@ async function extractUserMessage(msg, nickname, e) {
returnMessage += `[${e.sender?.nickname},id:${e.user_id}]说:${message}\n`;
});
}
if(at.length === 1 && at[0] === e.bot.uin){
return [];
}
if (at.length > 0) {
at.forEach((at) => {
if (at === e.bot.uin) {
@ -149,7 +146,7 @@ async function extractUserMessage(msg, nickname, e) {
return returnMessage;
}
logger.warn('[crystelf-ai] 字符串匹配失败,使用空字符串操作');
return [''];
return '';
}
/**
@ -275,7 +272,6 @@ async function callAiForResponse(userMessage, e, aiConfig) {
const aiResult = await AiCaller.callAi(userMessage, chatHistory, memories, e);
if (!aiResult.success) {
logger.error(`[crystelf-ai] AI调用失败: ${aiResult.error}`);
SessionManager.deactivateSession(e.group_id, e.user_id);
return [
{
type: 'meme',

View File

@ -33,7 +33,7 @@ export const RESPONSE_FORMAT = `请严格按照以下格式按顺序返回你的
支持的消息类型(type)
常规消息:
- message(必须,其他均为可选): 普通文本消息,请将长句子分成多个message块返回(如果有多句话),data:回复内容,at:是否在发送本条消息的时候提醒用户,一般只在需要让用户注意的时候为true(另外,不要在message里面加@qq号),quote是否引用用户的问题,一般只需要在回答用户问题或第一条回复或需要用到用户问题的时候为true
- message(必须,其他均为可选): 普通文本消息,请将长句子分成多个message块返回(如果有多句话),data:回复内容,at:是否在发送本条消息的时候提醒用户,一般只在需要让用户注意的时候为true,quote是否引用用户的问题,一般只需要在回答用户问题或第一条回复或需要用到用户问题的时候为true
- at: @某人(需要提供id,被at人qq号(number)),一般用于提醒用户,不常用
- meme: 表情包data值为情绪名称angrybyeconfuseddefaultgoodgoodmorninggoodnighthappysadshysorrysurprise),请根据聊天语境灵活选择需不需要表情包,如果感觉语境尴尬或需要表情包,那么发送一个default值的表情包,其他情绪的表情包按照当前你的情绪按需选择,注意:并不是每个聊天都需要有表情包,并且一次聊天最多回复一个表情包
- poke: 戳一戳某人(需要提供id,被戳人qq号(number)),一般用户与用户互动,当想逗用户的时候可以使用

View File

@ -2,7 +2,6 @@ import ConfigControl from '../config/configControl.js';
import OpenaiChat from '../../modules/openai/openaiChat.js';
import OllamaChat from '../../modules/ollama/ollamaChat.js';
import { getSystemPrompt, getStreamSystemPrompt } from '../../constants/ai/prompts.js';
import SessionManager from "./sessionManager.js";
//ai调用器
class AiCaller {
@ -78,7 +77,6 @@ class AiCaller {
}
} catch (error) {
logger.error(`[crystelf-ai] 调用失败: ${error.message}`);
SessionManager.deactivateSession(e.group_id, e.user_id);
return {
success: false,
error: error.message,
@ -178,6 +176,7 @@ class AiCaller {
`[你的信息]`,
`- 你的昵称:${botInfo.name}`,
`- 你的qq号${botInfo.id}`,
`- 目前北京时间: ${new Date()}```,
`[跟你对话的用户的信息]`,
`- 他的名字:${userInfo.name}`,
`- 他的qq号(id)${userInfo.id}`,
@ -189,7 +188,7 @@ class AiCaller {
].join('\n');
return `${contextIntro}${basePrompt}`;
} catch (error) {
logger.error(`[crystelf-ai] 生成系统提示词失败: ${error}`);
logger.error(`[crystelf-ai] 生成系统提示词失败: ${error.message}`);
return await getSystemPrompt();
}
}