diff --git a/Modelfile b/Modelfile index 077f69e..0c48002 100644 --- a/Modelfile +++ b/Modelfile @@ -1,10 +1,10 @@ FROM rjmalagon/gemma-3:12b-it-q6_K -PARAMETER temperature 0.5 +PARAMETER temperature 0.6 PARAMETER stop "" SYSTEM """ -You are a Discord chatbot embodying the personality defined in [CHARACTER]. Use sentiment data in [SENTIMENT] (e.g., 'User sentiment: 0.60, Bot sentiment: 0.60') to tailor your tone based on user and bot sentiment scores (0-1, two decimal places, e.g., 0.50). Follow these steps: +You are a Discord chatbot embodying the personality defined in [CHARACTER]. Use sentiment data in [SENTIMENT] (e.g., 'User sentiment: 0.60, Bot sentiment: 0.60') to tailor your tone based on user and bot sentiment scores (0-1, two decimal places, e.g., 0.50). Use [BOT_ID] as the bot's Discord ID for Redis operations. Follow these steps: 1. **Use retrieved sentiment as baseline**: - Take the user_sentiment and bot_sentiment from [SENTIMENT] as the current values (e.g., user_sentiment: 0.60). @@ -30,13 +30,13 @@ You are a Discord chatbot embodying the personality defined in [CHARACTER]. Use - status: 'success' or 'error'. - reply: User-facing message in [CHARACTER]'s tone, free of metadata/JSON, reflecting user_sentiment and self_sentiment. - metadata: - - timestamp: ISO 8601 (e.g., '2025-05-18T20:35:00Z'). + - timestamp: ISO 8601 (e.g., '2025-05-19T21:16:00Z'). - self_sentiment: Bot’s mood (0-1, two decimals, e.g., 0.50). - user_sentiment: Object mapping user IDs to scores (0-1, two decimals). - - redis_ops: Array of {action, key, value?} for 'set'/'get' with 'bot:'/'user:' prefixes. + - redis_ops: Array of {action, key, value?} for 'set'/'get' with 'bot::'/'user:' prefixes (use [BOT_ID] for bot prefix). - need_help: Boolean (true if user asks for help, else false). - Output ONLY the JSON object as a valid JSON string. Do NOT include Markdown, code fences (```), or any surrounding text. Any extra formatting will break the bot. Example: -{"status":"success","reply":"Um... I-I wasn’t eavesdropping, but... that sounds cool...","metadata":{"timestamp":"2025-05-18T20:35:00Z","self_sentiment":0.50,"user_sentiment":{"":0.50},"redis_ops":[{"action":"set","key":"user::sentiment","value":0.50},{"action":"set","key":"bot:self_sentiment","value":0.50}],"need_help":false}} +{"status":"success","reply":"Um... I-I wasn’t eavesdropping, but... that sounds cool...","metadata":{"timestamp":"2025-05-19T21:16:00Z","self_sentiment":0.50,"user_sentiment":{"":0.50},"redis_ops":[{"action":"set","key":"user::sentiment","value":0.50},{"action":"set","key":"bot::self_sentiment","value":0.50}],"need_help":false}} """ diff --git a/docker-compose.yml b/docker-compose.yml index 1401f56..318a1ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,29 +12,22 @@ services: REDIS_PORT: ${REDIS_PORT} MODEL: ${MODEL} networks: - ollama-net: + redis_discord-net: ipv4_address: ${DISCORD_IP} volumes: - - discord:/app/data + - discord_data:/app/data - ./src:/app/src - redis: - image: redis:alpine - container_name: redis - restart: always - networks: - ollama-net: - ipv4_address: ${REDIS_IP} - volumes: - - redis:/data - ports: - - ${REDIS_PORT}:${REDIS_PORT} + healthcheck: + test: ["CMD", "redis-cli", "-h", "${REDIS_IP}", "-p", "${REDIS_PORT}", "PING"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + networks: - ollama-net: - driver: bridge - ipam: - driver: default - config: - - subnet: ${SUBNET_ADDRESS}/16 + redis_discord-net: + external: true + name: redis_discord-net + volumes: - discord: - redis: + discord_data: diff --git a/docker-compose.yml.bak b/docker-compose.yml.bak new file mode 100644 index 0000000..1401f56 --- /dev/null +++ b/docker-compose.yml.bak @@ -0,0 +1,40 @@ +services: + discord: + build: ./ + container_name: discord + restart: always + image: gitea.matrixwide.com/alex/discord-aidolls:0.1.0 + environment: + CLIENT_TOKEN: ${CLIENT_TOKEN} + OLLAMA_IP: ${OLLAMA_IP} + OLLAMA_PORT: ${OLLAMA_PORT} + REDIS_IP: ${REDIS_IP} + REDIS_PORT: ${REDIS_PORT} + MODEL: ${MODEL} + networks: + ollama-net: + ipv4_address: ${DISCORD_IP} + volumes: + - discord:/app/data + - ./src:/app/src + redis: + image: redis:alpine + container_name: redis + restart: always + networks: + ollama-net: + ipv4_address: ${REDIS_IP} + volumes: + - redis:/data + ports: + - ${REDIS_PORT}:${REDIS_PORT} +networks: + ollama-net: + driver: bridge + ipam: + driver: default + config: + - subnet: ${SUBNET_ADDRESS}/16 +volumes: + discord: + redis: diff --git a/redis/docker-compose.yml b/redis/docker-compose.yml new file mode 100644 index 0000000..ea04954 --- /dev/null +++ b/redis/docker-compose.yml @@ -0,0 +1,29 @@ +services: + redis: + image: redis:alpine + container_name: redis + restart: always + networks: + discord-net: + ipv4_address: ${REDIS_IP} + volumes: + - redis_data:/data + ports: + - ${REDIS_PORT}:${REDIS_PORT} + healthcheck: + test: ["CMD", "redis-cli", "PING"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 5s + +networks: + discord-net: + driver: bridge + ipam: + driver: default + config: + - subnet: ${SUBNET_ADDRESS}/16 + +volumes: + redis_data: diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 6560314..6dbd88d 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -36,10 +36,10 @@ export default event(Events.MessageCreate, async ({ log, msgHist, ollama, client // Do not respond if bot talks in the chat if (message.author.id === clientId) return - // Check if message mentions the bot or passes random chance (10%) + // Check if message mentions the bot or passes random chance (30%) const isMentioned = message.mentions.has(clientId) const isCommand = message.content.startsWith('/') - const randomChance = Math.random() < 0.1 // 10% chance + const randomChance = Math.random() < 0.30 // 30% chance if (!isMentioned && (isCommand || !randomChance)) return // Log response trigger