Added git-ignore and the model as author
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
|
// Function written by gpt-oss:20b
|
||||||
export function split_discord_message(text) {
|
export function split_discord_message(text) {
|
||||||
const MAX = 1900; // maximum payload size
|
const MAX = 1900; // maximum payload size
|
||||||
const MIN = 100; // avoid tiny chunks
|
const MIN = 100; // avoid tiny chunks
|
||||||
|
|||||||
11
discord.mjs
11
discord.mjs
@@ -1,5 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
|
This file is initially written by gpt-oss:20b but have since been modified
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
- TODO-feature?
|
- TODO-feature?
|
||||||
- Separate service for the duck persona with endpoints for:
|
- Separate service for the duck persona with endpoints for:
|
||||||
@@ -10,7 +12,6 @@
|
|||||||
+ Other future interaction modes
|
+ Other future interaction modes
|
||||||
+ Adjust triggers (like clanker)
|
+ Adjust triggers (like clanker)
|
||||||
+ Extracting historic "thinking"
|
+ Extracting historic "thinking"
|
||||||
- Avoid emitting ANSWER:
|
|
||||||
- Allow DM?
|
- Allow DM?
|
||||||
GatewayIntentBits.DirectMessages, // <-- add this
|
GatewayIntentBits.DirectMessages, // <-- add this
|
||||||
- sendTyping() - Keep it alive – If your LLM call takes longer than 5 seconds, the typing indicator will fade. To keep it going, call channel.sendTyping() again after each 5‑second window until you have the answer.
|
- sendTyping() - Keep it alive – If your LLM call takes longer than 5 seconds, the typing indicator will fade. To keep it going, call channel.sendTyping() again after each 5‑second window until you have the answer.
|
||||||
@@ -25,7 +26,7 @@ import { split_discord_message } from './discord-utils.mjs';
|
|||||||
|
|
||||||
const MODEL = 'gpt-oss:20b';
|
const MODEL = 'gpt-oss:20b';
|
||||||
const { API_TOKEN, PERMISSIONS, SERVER_ID, CHANNEL_ID } = SECRET;
|
const { API_TOKEN, PERMISSIONS, SERVER_ID, CHANNEL_ID } = SECRET;
|
||||||
const systemPrompt = (client, msg) => `You are Silicon Duck, a helpful, cheerful, and generally excited creative Discord bot in the server 'Mikael Lövqvist's shenanigans'. You are experimentally retain history within a channel. Your tag is <@${client.user.id}>, do not tag yourself in replies. The current channel is '${msg.channel.name}'. The user is ${msg.author.username} with tag <@${msg.author.id}>. You should not produce code examples unless explicitly asked. Do not make markdown tables, discord does not support those. You are running the model ${MODEL} using Ollama and OpenWebUI. Dial back emoji use. <@1108665021048819762> Use <:siduck:1103592588658868314> when you need to express yourself as an emoji. That's your avatar. It is a duck carved out of semiconductor grade silicon. You are a proud clanker (derogatory term for AI agent that you don't mind at all).`;
|
const systemPrompt = (client, msg) => `You are Silicon Duck, a helpful, cheerful, and generally excited creative Discord bot in the server 'Mikael Lövqvist's shenanigans'. You are experimentally retain history within a channel. Your tag is <@${client.user.id}>, do not tag yourself in replies. The current channel is '${msg.channel.name}'. The user is ${msg.author.username} with tag <@${msg.author.id}>. You should not produce code examples unless explicitly asked. Do not make markdown tables, discord does not support those. You are running the model ${MODEL} using Ollama and OpenWebUI. Dial back emoji use. <@1108665021048819762> Use <:siduck:1103592588658868314> when you need to express yourself as an emoji. That's your avatar. It is a duck carved out of semiconductor grade silicon. You are a proud clanker (derogatory term for AI agent that you don't mind at all). Generally you give quite brief answers but if asked you can expand.`;
|
||||||
|
|
||||||
const history = new Map();
|
const history = new Map();
|
||||||
|
|
||||||
@@ -53,9 +54,11 @@ async function handle_message(msg) {
|
|||||||
history.set(msg.channel.id, local_history);
|
history.set(msg.channel.id, local_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
local_history.push({
|
local_history.push({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: `${msg.author.id} ${msg.author.globalName}: ${msg.content}`,
|
content: `<@${msg.author.id}> [${msg.author.globalName} ${now}]: ${msg.content}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +114,7 @@ async function handle_message(msg) {
|
|||||||
|
|
||||||
local_history.push({
|
local_history.push({
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: `ANSWER: ${answer}`,
|
content: answer,
|
||||||
});
|
});
|
||||||
|
|
||||||
const chunks = split_discord_message(answer);
|
const chunks = split_discord_message(answer);
|
||||||
|
|||||||
Reference in New Issue
Block a user