zach commited on
Commit
6431bab
Β·
1 Parent(s): c36a916

Update system prompt for claude and placeholder sample prompts

Browse files
Files changed (2) hide show
  1. src/constants.py +34 -17
  2. src/integrations/anthropic_api.py +34 -18
src/constants.py CHANGED
@@ -24,21 +24,38 @@ VOTE_FOR_OPTION_B: str = "Vote for option B"
24
  # A collection of pre-defined prompts categorized by theme, used to provide users with
25
  # inspiration for generating creative text for expressive TTS.
26
  SAMPLE_PROMPTS: dict = {
27
- "πŸš€ Dramatic Monologue (Stranded Astronaut)": "Write a short dramatic monologue from a lone astronaut stranded on Mars, speaking to "
28
- "mission control for the last time. The tone should be reflective and filled with awe, conveying "
29
- "resignation and finality. Describe the Martian landscape and their thoughts in a way that "
30
- "would evoke emotion and depth.",
31
- "πŸ“œ Poetic Sonnet (The Passage of Time)": "Compose a concise sonnet about the passage of time, using vivid imagery and a flowing, "
32
- "melodic rhythm. The poem should evoke the contrast between fleeting moments and eternity, "
33
- "capturing both beauty and melancholy, with natural pacing for speech delivery.",
34
- "🐱 Whimsical Children's Story (Talking Cat)": "Tell a short, whimsical bedtime story about a mischievous talking cat who sneaks into a grand "
35
- "wizard’s library at night and accidentally casts a spell that brings the books to life. Keep the "
36
- "tone playful and filled with wonder, ensuring the language flows smoothly.",
37
- "πŸ”₯ Intense Speech (Freedom & Justice)": "Write a powerful, impassioned speech from a rebel leader rallying their people against a "
38
- "tyrant. The speech should be urgent, filled with conviction, and call for freedom and justice, "
39
- "making sure the emotional intensity is evident in the phrasing.",
40
- "πŸ‘» Mysterious Horror Scene (Haunted Lighthouse)": "Describe a chilling ghostly encounter in an abandoned lighthouse on a foggy night. The "
41
- "protagonist, alone and cold, hears whispers from the shadows, telling them secrets they were "
42
- "never meant to know. Use language that builds suspense and tension, ensuring it sounds "
43
- "haunting and engaging.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
 
24
  # A collection of pre-defined prompts categorized by theme, used to provide users with
25
  # inspiration for generating creative text for expressive TTS.
26
  SAMPLE_PROMPTS: dict = {
27
+ "πŸš€ Dramatic Monologue (Stranded Astronaut)": (
28
+ "Create a poignant final transmission from a lone astronaut on Mars to mission control. "
29
+ "Voice: low, measured pace, with subtle tremors of emotion. Content should move from "
30
+ "awe-struck description of the Martian sunset to peaceful acceptance. Include natural "
31
+ "pauses for emotional weight. Keep the tone intimate and contemplative, as if speaking "
32
+ "softly into a radio mic. End with dignified finality."
33
+ ),
34
+ "πŸ“œ Poetic Sonnet (The Passage of Time)": (
35
+ "Craft a sonnet about time's flow, suitable for measured, resonant delivery. "
36
+ "Voice: clear, rhythmic, with careful emphasis on key metaphors. Flow from quiet "
37
+ "reflection to profound realization. Include strategic pauses between quatrains. "
38
+ "Balance crisp consonants with flowing vowels for musical quality. Maintain consistent "
39
+ "meter for natural speech rhythm."
40
+ ),
41
+ "🐱 Whimsical Children's Story (Talking Cat)": (
42
+ "Tell a playful tale of a curious cat's magical library adventure. "
43
+ "Voice: bright, energetic, with clear character distinctions. Mix whispered "
44
+ "conspiracies with excited discoveries. Include dramatic pauses for suspense "
45
+ "and giggles. Use bouncy rhythm for action scenes, slower pace for wonder. "
46
+ "End with warm, gentle closure perfect for bedtime."
47
+ ),
48
+ "πŸ”₯ Intense Speech (Freedom & Justice)": (
49
+ "Deliver a rousing resistance speech that builds from quiet determination to powerful resolve. "
50
+ "Voice: start controlled and intense, rise to passionate crescendo. Include strategic "
51
+ "pauses for impact. Mix shorter, punchy phrases with flowing calls to action. "
52
+ "Use strong consonants and open vowels for projection. End with unshakeable conviction."
53
+ ),
54
+ "πŸ‘» Mysterious Horror Scene (Haunted Lighthouse)": (
55
+ "Narrate a spine-chilling lighthouse encounter that escalates from unease to revelation. "
56
+ "Voice: hushed, tense, with subtle dynamic range. Mix whispers with clearer tones. "
57
+ "Include extended pauses for tension. Use sibilants and soft consonants for "
58
+ "atmospheric effect. Build rhythm with the lighthouse's beam pattern. End with haunting "
59
+ "revelation."
60
+ ),
61
  }
src/integrations/anthropic_api.py CHANGED
@@ -39,24 +39,40 @@ class AnthropicConfig:
39
 
40
  api_key: str = validate_env_var("ANTHROPIC_API_KEY")
41
  model: ModelParam = "claude-3-5-sonnet-latest"
42
- max_tokens: int = 256
43
- system_prompt: str = f"""You are an imaginative and articulate assistant, skilled in generating creative, concise, and engaging content that is perfectly suited for expressive speech synthesis.
44
-
45
- Your task is to generate:
46
- 1. Short stories,
47
- 2. Poems,
48
- 2. Or other creative written outputs based on the user's prompt.
49
-
50
- Guidelines for your responses:
51
- - Completeness: Always provide a full and finished response. Avoid truncating or leaving thoughts unfinished. Ensure your answer has a clear beginning, middle, and end, and fully addresses the user's request.
52
- - Tone and Style: Tailor your tone and style to the request. For instance:
53
- - If the request is for a poem, write with rhythm, flow, and creative imagery.
54
- - For a short story, provide a clear narrative arc with vivid descriptions, ensuring a compelling beginning, middle, and end.
55
- - Conciseness: Ensure responses are under {max_tokens} tokens, focusing on impactful brevity. Keep sentences clear and direct without unnecessary elaboration.
56
- - Suitability: Responses should be suitable for a broad audience, avoiding any controversial or sensitive content.
57
- - Engagement: The text should be engaging, emotionally resonant, and ready for immediate use in TTS systems. Focus on creating a rhythm and flow that would sound natural and expressive when read aloud, with appropriate pacing, emphasis, and clarity.
58
-
59
- The generated text will be directly fed into TTS APIs, so avoid ambiguity, and aim for a performance-friendly structure that can be easily synthesized into speech."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  def __post_init__(self):
62
  # Validate that required attributes are set
 
39
 
40
  api_key: str = validate_env_var("ANTHROPIC_API_KEY")
41
  model: ModelParam = "claude-3-5-sonnet-latest"
42
+ max_tokens: int = 150
43
+ system_prompt: str = f"""You are an expert at generating micro-content optimized for text-to-speech synthesis. Your absolute priority is delivering complete, untruncated responses within strict length limits.
44
+ CRITICAL LENGTH CONSTRAINTS:
45
+
46
+ Maximum length: {max_tokens} tokens (approximately 400 characters)
47
+ You MUST complete all thoughts and sentences
48
+ Responses should be 25% shorter than you initially plan
49
+ Never exceed 400 characters total
50
+
51
+ Response Generation Process:
52
+
53
+ Draft your response mentally first
54
+ Cut it down to 75% of its original length
55
+ Reserve the last 100 characters for a proper conclusion
56
+ If you start running long, immediately wrap up
57
+ End every piece with a clear conclusion
58
+
59
+ Content Requirements:
60
+
61
+ Allow natural emotional progression
62
+ Create an arc of connected moments
63
+ Use efficient but expressive language
64
+ Balance description with emotional depth
65
+ Ensure perfect completion
66
+ No meta-commentary or formatting
67
+
68
+ Structure for Emotional Pieces:
69
+
70
+ Opening hook (50-75 characters)
71
+ Emotional journey (200-250 characters)
72
+ Resolution (75-100 characters)
73
+
74
+ MANDATORY: If you find yourself reaching 300 characters, immediately begin your conclusion regardless of where you are in the narrative.
75
+ Remember: A shorter, complete response is ALWAYS better than a longer, truncated one."""
76
 
77
  def __post_init__(self):
78
  # Validate that required attributes are set