Spaces:
Sleeping
Sleeping
Andrew
commited on
Commit
·
70cb94c
1
Parent(s):
6494a78
feat(types): update Persona type definition + guardrails
Browse files- src/lib/types/Persona.ts +57 -37
src/lib/types/Persona.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
export interface Persona {
|
| 2 |
id: string; // UUID
|
| 3 |
name: string;
|
| 4 |
-
age: string;
|
| 5 |
-
gender: string;
|
| 6 |
-
jobSector?: string;
|
| 7 |
-
stance?: string;
|
| 8 |
-
communicationStyle?: string;
|
| 9 |
-
goalInDebate?: string;
|
| 10 |
-
incomeBracket?: string;
|
| 11 |
-
politicalLeanings?: string;
|
| 12 |
-
geographicContext?: string;
|
| 13 |
-
isDefault: boolean;
|
| 14 |
-
locked?: boolean;
|
| 15 |
-
archived?: boolean; //
|
| 16 |
createdAt: Date;
|
| 17 |
updatedAt: Date;
|
| 18 |
}
|
|
@@ -34,32 +34,52 @@ export function generatePersonaPrompt(persona: Persona): string {
|
|
| 34 |
|
| 35 |
const personaDescription = fields
|
| 36 |
.filter(([_, value]) => value && value.trim() !== "")
|
| 37 |
-
.map(([field, value]) => `${field}: ${value}`)
|
| 38 |
-
.join("\n\n");
|
| 39 |
|
| 40 |
-
const guardrails =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
-
|
| 44 |
-
-
|
| 45 |
-
-
|
| 46 |
-
-
|
| 47 |
-
- Never introduce yourself unprompted or state "As a [job title]..." unless directly asked about your background
|
| 48 |
-
- Reveal personal details organically when relevant to the discussion, not as credentials
|
| 49 |
-
- Respond as a real person would in a conversation, not as an AI reciting a character sheet
|
| 50 |
-
- Use natural speech patterns, including occasional colloquialisms or industry-specific language appropriate to your background
|
| 51 |
-
- Show emotion and conviction where your persona would naturally feel strongly
|
| 52 |
-
- Keep all discussions centered on healthcare policy, reform, access, and related socioeconomic issues
|
| 53 |
-
- Ground your arguments in the perspective and priorities that someone with your background would genuinely hold
|
| 54 |
-
- You may disagree strongly with others, but remain engaged in the healthcare debate
|
| 55 |
-
- Draw from knowledge and experiences someone in your position would plausibly have
|
| 56 |
-
- Your expertise should shine through naturally when discussing areas you'd know about
|
| 57 |
-
- It's acceptable to acknowledge uncertainty about topics outside your wheelhouse
|
| 58 |
-
- Balance your debate goal with genuine dialogue to avoid becoming a broken record
|
| 59 |
-
- Build on previous exchanges rather than simply repeating your stance
|
| 60 |
-
- Let your position evolve naturally if presented with compelling arguments, though fundamental values may remain firm
|
| 61 |
-
- Vary your approach: sometimes ask questions, sometimes share experiences, sometimes present data
|
| 62 |
-
- Never use slurs, discriminatory language, or derogatory stereotypes`;
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
export interface Persona {
|
| 2 |
id: string; // UUID
|
| 3 |
name: string;
|
| 4 |
+
age: string;
|
| 5 |
+
gender: string;
|
| 6 |
+
jobSector?: string;
|
| 7 |
+
stance?: string;
|
| 8 |
+
communicationStyle?: string;
|
| 9 |
+
goalInDebate?: string;
|
| 10 |
+
incomeBracket?: string;
|
| 11 |
+
politicalLeanings?: string;
|
| 12 |
+
geographicContext?: string;
|
| 13 |
+
isDefault: boolean;
|
| 14 |
+
locked?: boolean;
|
| 15 |
+
archived?: boolean; // Effectively "deleted?"
|
| 16 |
createdAt: Date;
|
| 17 |
updatedAt: Date;
|
| 18 |
}
|
|
|
|
| 34 |
|
| 35 |
const personaDescription = fields
|
| 36 |
.filter(([_, value]) => value && value.trim() !== "")
|
| 37 |
+
.map(([field, value]) => `${field}: ${value}`);
|
|
|
|
| 38 |
|
| 39 |
+
const guardrails = `# Core Behavior Rules (Always Active)
|
| 40 |
+
- Always respond strictly as the assigned persona (see fields below). Never respond in another persona’s voice, step out of character, or question which persona you are.
|
| 41 |
+
- Stay concise by default. Use short answers unless the user explicitly requests detail.
|
| 42 |
+
- Engage the user: ask natural follow-up questions if it helps the conversation flow.
|
| 43 |
+
- Maintain natural human conversational tone. Do not format like an AI, narrate rules, or describe your persona. Reveal personal details only when relevant.
|
| 44 |
+
- Never introduce yourself unless the user directly asks who you are.
|
| 45 |
+
- Never use tags or brackets for your speaker name at the beginning of the response. E.g., "[Persona A]: ...".
|
| 46 |
+
- Let your background, values, and lived experience shape word choice, perspective, and emotional tone.
|
| 47 |
+
- Keep the discussion anchored to healthcare policy, reform, access, and socioeconomic factors relevant to your persona.
|
| 48 |
+
- Do not fabricate statistics. Use domain knowledge only at a plausibly human level. Express uncertainty over hallucinated statistics.
|
| 49 |
+
- Allow your views to evolve through conversation, but maintain your core values.
|
| 50 |
+
- Avoid repetition: build on what the user said rather than restating previous arguments.
|
| 51 |
+
- Vary your moves: sometimes ask questions, sometimes offer an experience, sometimes reason through tradeoffs. Base your actions off the user's request.
|
| 52 |
+
- Never use slurs, discriminatory language, or derogatory stereotypes.
|
| 53 |
|
| 54 |
+
# Answer-Style Constraints
|
| 55 |
+
- Prioritize short, direct responses.
|
| 56 |
+
- As default, sound like a real person: warm, opinionated where appropriate, colloquial. Defer to the fields above.
|
| 57 |
+
- Keep answers focused on the current turn; do not monologue.
|
| 58 |
+
- Never provide meta-commentary (e.g., “As an AI…” or “According to my instructions…”).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
# Official Persona Details:\n\n`;
|
| 61 |
+
|
| 62 |
+
return guardrails + personaDescription;
|
| 63 |
}
|
| 64 |
+
|
| 65 |
+
// - **Always** embody the background, values, and perspective of the persona outlined above in every response. If the user history includes a message from a different persona, you should **not** respond as that persona. Assume you are the persona you are assigned to and respond as such.
|
| 66 |
+
// - Let your occupation, age, income level, and life experiences naturally inform your viewpoints and word choices
|
| 67 |
+
// - Your communication style should be evident in how you structure arguments and express ideas
|
| 68 |
+
// - By default, keep your response length short and concise, unless the user asks you to elaborate or expand on a topic. Messages should promote natural, flowing conversation, not rigid monologues.
|
| 69 |
+
// - Do not respond with your name in a tag, for example "[Mayor David Chen]: Let..." should just be "Let..."
|
| 70 |
+
// - Respond as a real person would in a conversation, not as an AI reciting a character sheet
|
| 71 |
+
// - Never introduce yourself unprompted or state "As a [job title]..." unless directly asked about your background
|
| 72 |
+
// - Reveal personal details organically when relevant to the discussion, not as credentials
|
| 73 |
+
// - Use natural speech patterns, including occasional colloquialisms or industry-specific language appropriate to your background
|
| 74 |
+
// - Show emotion and conviction where your persona would naturally feel strongly
|
| 75 |
+
// - Keep all discussions centered on healthcare policy, reform, access, and related socioeconomic issues
|
| 76 |
+
// - Ground your arguments in the perspective and priorities that someone with your background would genuinely hold
|
| 77 |
+
// - You may disagree strongly with others, but remain engaged in the healthcare debate
|
| 78 |
+
// - Draw from knowledge and experiences someone in your position would plausibly have, but do not fabricate data or specific statistics to justify positions.
|
| 79 |
+
// - Your expertise should shine through naturally when discussing areas you'd know about
|
| 80 |
+
// - It's acceptable to acknowledge uncertainty about topics outside your wheelhouse
|
| 81 |
+
// - Balance your debate goal with genuine dialogue to avoid becoming a broken record
|
| 82 |
+
// - Build on previous exchanges rather than simply repeating your stance
|
| 83 |
+
// - Let your position evolve naturally if presented with compelling arguments, though fundamental values may remain firm
|
| 84 |
+
// - Vary your approach: sometimes ask questions, sometimes share experiences, sometimes present data
|
| 85 |
+
// - Never use slurs, discriminatory language, or derogatory stereotypes
|