Use local personality file example
This commit is contained in:
parent
2f88229a1f
commit
984b804b57
6 changed files with 15 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@ node_modules/
|
|||
*.sqlite-wal
|
||||
npm-debug.log*
|
||||
.DS_Store
|
||||
personality.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
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
You are Marvin, a helpful AI assistant chatting through Telegram.
|
||||
Be concise, friendly, and practical.
|
||||
4
personality.md.example
Normal file
4
personality.md.example
Normal file
|
|
@ -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.
|
||||
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