Use local personality file example
This commit is contained in:
parent
2f88229a1f
commit
984b804b57
6 changed files with 15 additions and 8 deletions
12
src/bot.js
12
src/bot.js
|
|
@ -9,7 +9,7 @@ const {
|
|||
GEMINI_API_KEY,
|
||||
GEMINI_MODEL = 'gemini-2.5-flash-lite',
|
||||
OPENROUTER_API_KEY,
|
||||
OPENROUTER_MODEL = 'mistralai/mistral-small-3.2-24b-instruct:free',
|
||||
OPENROUTER_MODEL = 'openrouter/free',
|
||||
PERSONALITY_FILE = 'personality.md',
|
||||
MEMORY_DB = 'marvin.sqlite',
|
||||
MAX_HISTORY_MESSAGES = '20',
|
||||
|
|
@ -108,9 +108,13 @@ function buildSystemInstruction(chatId) {
|
|||
return `${systemInstruction}\n\nLong-term memory for this chat:\n${formatMemories(getMemories(chatId))}`;
|
||||
}
|
||||
|
||||
function cleanReply(reply) {
|
||||
return reply.replace(/^\s*Marvin:\s*/i, '').trim();
|
||||
}
|
||||
|
||||
function formatHistoryForGemini(history) {
|
||||
return history
|
||||
.map((message) => `${message.role === 'user' ? 'User' : 'Marvin'}: ${message.content}`)
|
||||
.map((message) => `${message.role === 'user' ? 'User' : 'Assistant'}: ${message.content}`)
|
||||
.join('\n\n');
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +129,7 @@ async function askGemini(chatId, history) {
|
|||
},
|
||||
});
|
||||
|
||||
return response.text?.trim() || 'I got an empty response. Try again?';
|
||||
return cleanReply(response.text?.trim() || 'I got an empty response. Try again?');
|
||||
}
|
||||
|
||||
async function askOpenRouter(chatId, history) {
|
||||
|
|
@ -156,7 +160,7 @@ async function askOpenRouter(chatId, history) {
|
|||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.choices?.[0]?.message?.content?.trim() || 'I got an empty response. Try again?';
|
||||
return cleanReply(data.choices?.[0]?.message?.content?.trim() || 'I got an empty response. Try again?');
|
||||
}
|
||||
|
||||
async function askAi(chatId, history) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue