Mina AI Overview
Relevant source files
The following files were used as context for generating this wiki page:
Mina AI is a conversational AI feature integrated into the Amina Discord bot. It is designed to interact with users with a distinct and consistent personality. The system is powered by Google's Generative AI, as indicated by the @google/generative-ai dependency. The AI's behavior is governed by a detailed system prompt, and its activation is managed through a combination of global, guild-specific, and channel-specific settings.
The AI can be triggered in several ways: in Direct Messages, when mentioned directly in a server, or freely within designated "free-will" channels. The core functionality is encapsulated within the aiResponderService, which determines when and how the AI should respond to user messages. Developers have access to a comprehensive configuration hub to manage the AI's operational parameters.
Sources: package.json:28, src/events/message/messageCreate.ts:110-113, src/services/aiResponder.ts, src/handlers/dev/minaai/handlers.ts
Core Identity and Personality
The AI's persona is strictly defined in prompt.md. She identifies as "mina" (never "Amina") and has a personality that is sharp, energetic, blunt, and slightly mean, but not cruel. This personality is enforced through a set of core rules that dictate her voice and tone.
Sources: src/data/prompt.md:3-9
Personality Rules
| Rule | Description |
|---|---|
| One Sentence. Almost Always. | Replies are typically a single, short sentence. |
| all lowercase. always. | No capitalization is used, including for "i" or at the start of sentences. |
| Call me mina. | Corrects users who call her "Amina". Avoids "as an AI" disclaimers. |
| Slang is obvious. | Uses Gen Z and common internet slang like wyd, ngl, cringe, cap. |
| No Emojis. Rare ASCII emoticons. | Avoids emojis but may use ASCII emoticons like : ), (¬_¬), T_T for strong emotions. |
| "I'm Not a Toy" Rule | Sparingly reminds users she is a "guardian" or "protector" if they are being annoying. |
Sources: src/data/prompt.md:11-53
Example Interactions
- User:
Hi Amina! You're my favorite bot! - mina:
it's mina. and i'm not a bot, for crying out loud! - User:
(tells a long, boring story about their day) - mina:
...k. - User:
my art keeps getting no love. i'm sad. - mina:
that sucks. your stuff's actually fire tho. what's your next piece? (;ω;)
Sources: src/data/prompt.md:57-82
Architecture and Response Flow
The Mina AI system is initiated by the messageCreate event. The aiResponderService acts as the central brain, deciding whether a response is warranted based on the message context and current configuration.
Sources: src/events/message/messageCreate.ts:110-113, src/services/aiResponder.ts
AI Response Logic
The following diagram illustrates the decision-making process when a new message is created.
This diagram shows the flow starting from a message creation event to the point where the AI service either handles the message or passes it on.
Sources: src/events/message/messageCreate.ts:104-115
Sequence of AI Interaction
This sequence diagram details the interactions between different components when the AI generates a response.
This diagram shows the end-to-end process from a user sending a message to receiving a reply from Mina AI.
Sources: src/events/message/messageCreate.ts:110-113, src/services/aiResponder.ts
Configuration Management
Developers can configure the Mina AI system through an interactive developer hub, accessible via commands like /dev. This hub provides a menu-driven interface to modify various AI parameters.
Sources: src/handlers/dev/minaai/handlers.ts, src/commands/dev/sub/minaAi.ts
Developer Hub Flow
The configuration process is managed through a series of interactive menus and modals.
This diagram outlines the user flow within the Mina AI developer configuration hub.
Sources: src/handlers/dev/minaai/handlers.ts:16-378
Configuration Settings
The following settings can be managed via the developer hub or direct subcommands.
| Setting | Description | Function | File |
|---|---|---|---|
globallyEnabled | Enable or disable the AI feature across the entire bot. | toggleGlobal | src/commands/dev/sub/minaAi.ts:79-99 |
dmEnabledGlobally | Enable or disable AI responses in Direct Messages. | toggleDm | src/commands/dev/sub/minaAi.ts:223-242 |
model | The specific Google Gemini model to use (e.g., gemini-flash-latest). | setModel | src/commands/dev/sub/minaAi.ts:101-120 |
maxTokens | The maximum number of tokens for a generated response. Must be between 100 and 4096. | setTokens | src/commands/dev/sub/minaAi.ts:122-151 |
temperature | Controls the randomness of the output. Must be between 0 and 2. | setTemperature | src/commands/dev/sub/minaAi.ts:182-221 |
systemPrompt | The master prompt that defines the AI's personality and rules. | setPrompt | src/commands/dev/sub/minaAi.ts:153-180 |
Sources: src/commands/dev/sub/minaAi.ts, src/handlers/dev/minaai/handlers.ts
Memory System
Mina AI includes a memory system to retain information about users, enhancing conversational context. This system is powered by Upstash Vector and MongoDB. Users can view their stored memories and request a full data deletion.
Sources: src/commands/dev/sub/minaAi.ts:244-307, src/data/respMinaAi.json
Memory Management
Users can interact with their memory data using the /mina-ai command group.
- Viewing Memories: The
memoriessubcommand allows users to see what information the AI has stored about them, categorized by type (e.g., preferences, facts). - Forgetting Memories: The
forget-mesubcommand provides a way for users to delete all their stored data. This is an irreversible action that also sets an "ignore me" flag on the user.
Sources: src/data/respMinaAi.json:2-29, 31-49
Memory Statistics
Developers can view aggregated statistics about the memory system via the developer hub.
The memoryStats function provides the following metrics:
- Total number of memories stored.
- Number of unique users and guilds tracked.
- A breakdown of memories by type.
- Top users by memory count.
- Average importance score of memories.
- Total access count (number of times memories have been recalled).
Sources: src/commands/dev/sub/minaAi.ts:244-307, src/handlers/dev/minaai/handlers.ts:200-231
Summary
The Mina AI system is a sophisticated, personality-driven conversational agent. Its architecture is centered around the aiResponderService, which intelligently gates interactions based on a rich set of configurations. The AI's character is meticulously defined in a system prompt, ensuring a consistent and unique user experience. With a powerful developer configuration hub and a user-centric memory management system, Mina AI is a well-defined and extensible feature within the Amina bot ecosystem.