Spaces:
Running
Running
zach
commited on
Commit
Β·
6431bab
1
Parent(s):
c36a916
Update system prompt for claude and placeholder sample prompts
Browse files- src/constants.py +34 -17
- 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)":
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
"
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
"
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 =
|
43 |
-
system_prompt: str = f"""You are an
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|