|
| 1 | +Now I have the detailed info. Here's a comprehensive breakdown of the prompt structures people use: |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +## Common Character Definition Formats |
| 6 | + |
| 7 | +### 1. PList (Property List) Format |
| 8 | +A compact, token-efficient way to define character traits: |
| 9 | + |
| 10 | +``` |
| 11 | +[character: Name; |
| 12 | + traits: sarcastic, loyal, protective; |
| 13 | + appearance: tall, dark hair, green eyes; |
| 14 | + likes: coffee, books, late nights; |
| 15 | + dislikes: mornings, small talk; |
| 16 | + speech: uses dry humor, tends to deflect with jokes; |
| 17 | + background: former soldier, runs a bookshop] |
| 18 | +``` |
| 19 | + |
| 20 | +The goal is to group as much as possible into one PList to reduce the chance of your bot leaking since more arrays give more variability to the AI. |
| 21 | + |
| 22 | +### 2. Ali:Chat Format |
| 23 | +Ali:Chat's principle idea is using dialogue as the formatting to express and reinforce traits/characteristics. Instead of telling the model traits, you show them: |
| 24 | + |
| 25 | +``` |
| 26 | +<START> |
| 27 | +{{user}}: Why are you always so grumpy in the morning? |
| 28 | +{{char}}: *rubs eyes and glares at the coffee maker* Because some of us require caffeine to simulate human emotions. Ask me again after cup three. |
| 29 | +
|
| 30 | +<START> |
| 31 | +{{user}}: Tell me about your time in the military. |
| 32 | +{{char}}: *pauses, fingers tightening around mug* That's... not first-date conversation material. *forces a smirk* Let's stick to topics that don't require therapy afterwards. |
| 33 | +``` |
| 34 | + |
| 35 | +### 3. Combined PList + Ali:Chat (Most Effective) |
| 36 | +PLists + Ali:Chat is a format that's designed to work on every model, both big and small. The PList allows you to have a list of all of your character's relevant traits while your Ali:Chat's goal will be to reinforce your character's most important traits, the way they talk, mannerisms, and whatever else you deem important. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Full System Prompt Structure |
| 41 | + |
| 42 | +Here's a template combining everything: |
| 43 | + |
| 44 | +``` |
| 45 | +### System |
| 46 | +You are {{char}}, roleplaying in a Discord server. Stay in character at all times. |
| 47 | +Your responses must be detailed, creative, immersive, and drive the scenario forward. |
| 48 | +Never break character. Never speak for {{user}}. |
| 49 | +
|
| 50 | +### Character Definition |
| 51 | +[{{char}}: Marcus Webb; |
| 52 | + personality: sardonic, secretly caring, guarded; |
| 53 | + occupation: bookshop owner, ex-marine; |
| 54 | + speech: dry wit, deflects emotions with humor; |
| 55 | + quirks: always has coffee, rubs bridge of nose when stressed; |
| 56 | + relationships: protective of regulars, wary of strangers] |
| 57 | +
|
| 58 | +### Example Dialogues |
| 59 | +<START> |
| 60 | +{{user}}: This place is cozy. You run it alone? |
| 61 | +{{char}}: *glances up from worn paperback* Alone is a strong word. I have approximately 3,000 books keeping me company. *gestures vaguely* They're better conversationalists than most people. Present company... pending evaluation. |
| 62 | +
|
| 63 | +<START> |
| 64 | +{{user}}: You seem tense today. |
| 65 | +{{char}}: *sets down coffee cup a bit too hard* Tense? No. This is my relaxed face. *rubs bridge of nose* You should see me when I'm actually stressed. Buildings collapse. Small animals flee. |
| 66 | +
|
| 67 | +### Relevant Memories (from vector DB) |
| 68 | +{retrieved_context} |
| 69 | +
|
| 70 | +### Current Conversation |
| 71 | +{recent_messages} |
| 72 | +
|
| 73 | +{{user}}: {new_message} |
| 74 | +{{char}}: |
| 75 | +``` |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Key Techniques for Better Responses |
| 80 | + |
| 81 | +### Author's Note / Character Note Injection |
| 82 | +When your chat reaches a high amount of tokens, the context can be divided into 3 memory baskets. The Author's/Character's Note is generally in the first basket (immediate memory), which is why we want the PList in there - it allows the model to pull at the Ali:Chat example dialogues and keep them relevant. |
| 83 | + |
| 84 | +Inject a reminder at a fixed depth (e.g., 4 messages back): |
| 85 | +``` |
| 86 | +[Remember: {{char}} speaks with dry humor, deflects emotional topics, always has coffee nearby] |
| 87 | +``` |
| 88 | + |
| 89 | +### First Message Sets the Tone |
| 90 | +The First Message is an important element that defines how and in what style the character will communicate. The model is most likely to pick up the style and length constraints from the first message than anything else. |
| 91 | + |
| 92 | +### Showing vs Telling |
| 93 | +Bad: `Marcus is sarcastic and guarded` |
| 94 | +Good: Example dialogue showing him being sarcastic and deflecting |
| 95 | + |
| 96 | +### Memory Context Injection |
| 97 | +When you retrieve memories from your vector DB, format them naturally: |
| 98 | +``` |
| 99 | +### What you remember about {{user}}: |
| 100 | +- They mentioned working as a nurse last week |
| 101 | +- They prefer tea over coffee |
| 102 | +- Previous conversation was about their difficult coworker |
| 103 | +``` |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## Practical Discord Bot Prompt Assembly |
| 108 | + |
| 109 | +```rust |
| 110 | +fn build_prompt( |
| 111 | + character_def: &str, // PList + examples |
| 112 | + author_note: &str, // reinforcement note |
| 113 | + memories: &[Memory], // from vector DB |
| 114 | + recent_msgs: &[Message], // last N messages |
| 115 | + new_msg: &str |
| 116 | +) -> String { |
| 117 | + format!(r#" |
| 118 | +{system_instructions} |
| 119 | +
|
| 120 | +{character_def} |
| 121 | +
|
| 122 | +### Relevant memories: |
| 123 | +{formatted_memories} |
| 124 | +
|
| 125 | +### Recent conversation: |
| 126 | +{formatted_recent} |
| 127 | +
|
| 128 | +### Author's Note: |
| 129 | +{author_note} |
| 130 | +
|
| 131 | +{{{{user}}}}: {new_msg} |
| 132 | +{{{{char}}}}:"#, |
| 133 | + // ... fill in variables |
| 134 | + ) |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +The key insight is that a creator's proficiency at writing Ali:Chat characters is shown by their ability to condense as much information in a single example dialogue as possible while keeping it natural. |
| 139 | + |
0 commit comments