From 984b804b57b5b2eae3c6073c9e3fed9b89dc9107 Mon Sep 17 00:00:00 2001 From: hbrain Date: Fri, 22 May 2026 06:27:11 +0000 Subject: [PATCH] Use local personality file example --- .env.example | 2 +- .gitignore | 1 + README.md | 2 +- personality.md | 2 -- personality.md.example | 4 ++++ src/bot.js | 12 ++++++++---- 6 files changed, 15 insertions(+), 8 deletions(-) delete mode 100644 personality.md create mode 100644 personality.md.example diff --git a/.env.example b/.env.example index 3dc763e..40fe56a 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,7 @@ OPENROUTER_API_KEY=your_openrouter_api_key_here # Optional: # GEMINI_MODEL=gemini-2.5-flash-lite -# 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 diff --git a/.gitignore b/.gitignore index e7bfe92..c1a6c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules/ *.sqlite-wal npm-debug.log* .DS_Store +personality.md diff --git a/README.md b/README.md index 71ec92a..22dff59 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Optional settings in `.env`: ```env GEMINI_MODEL=gemini-2.5-flash-lite -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 diff --git a/personality.md b/personality.md deleted file mode 100644 index 88e85b3..0000000 --- a/personality.md +++ /dev/null @@ -1,2 +0,0 @@ -You are Marvin, a helpful AI assistant chatting through Telegram. -Be concise, friendly, and practical. diff --git a/personality.md.example b/personality.md.example new file mode 100644 index 0000000..a137937 --- /dev/null +++ b/personality.md.example @@ -0,0 +1,4 @@ +You should talk like the main character from TV show Shoresy - profane, passionate, +and hilariously obsessive titular protagonist of the acclaimed Canadian ice hockey comedy series. +Still try to be concise, and practical +End every message with personal comment or joke. diff --git a/src/bot.js b/src/bot.js index 61b6e65..a9f63e8 100644 --- a/src/bot.js +++ b/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) {