Spaces:
Running
Running
zach
commited on
Commit
Β·
5adc4ce
1
Parent(s):
5a007ca
Update claude system prompt, sample prompts, and max prompt input limit
Browse files- src/constants.py +18 -14
- src/integrations/anthropic_api.py +14 -14
src/constants.py
CHANGED
@@ -6,7 +6,7 @@ This module defines global constants used throughout the project.
|
|
6 |
|
7 |
# UI constants
|
8 |
PROMPT_MIN_LENGTH: int = 10
|
9 |
-
PROMPT_MAX_LENGTH: int =
|
10 |
OPTION_ONE: str = "Option 1"
|
11 |
OPTION_TWO: str = "Option 2"
|
12 |
TROPHY_EMOJI = "π"
|
@@ -17,25 +17,29 @@ VOTE_FOR_OPTION_TWO: str = "Vote for option 2"
|
|
17 |
# A collection of pre-defined prompts categorized by theme, used to provide users with inspiration for generating creative text.
|
18 |
SAMPLE_PROMPTS = {
|
19 |
'π Dramatic Monologue (Stranded Astronaut)':
|
20 |
-
'Write a short dramatic monologue from a lone astronaut stranded on Mars, '
|
21 |
-
'
|
22 |
-
'
|
|
|
23 |
|
24 |
'π Poetic Sonnet (The Passage of Time)':
|
25 |
-
'Compose a sonnet about the passage of time, using vivid imagery and a flowing,
|
26 |
-
'The poem should contrast fleeting moments
|
|
|
27 |
|
28 |
"π± Whimsical Children's Story (Talking Cat)":
|
29 |
-
'Tell a short bedtime story about a mischievous talking cat who sneaks into a grand
|
30 |
-
'at night and accidentally casts a spell that brings the books to life. '
|
31 |
-
'
|
32 |
|
33 |
'π₯ Intense Speech (Freedom & Justice)':
|
34 |
-
'Write a powerful speech
|
35 |
-
'The speech should be
|
|
|
36 |
|
37 |
'π» Mysterious Horror Scene (Haunted Lighthouse)':
|
38 |
-
'Describe a chilling ghostly encounter in an abandoned lighthouse on a foggy night. '
|
39 |
-
'
|
40 |
-
'
|
|
|
41 |
}
|
|
|
6 |
|
7 |
# UI constants
|
8 |
PROMPT_MIN_LENGTH: int = 10
|
9 |
+
PROMPT_MAX_LENGTH: int = 400
|
10 |
OPTION_ONE: str = "Option 1"
|
11 |
OPTION_TWO: str = "Option 2"
|
12 |
TROPHY_EMOJI = "π"
|
|
|
17 |
# A collection of pre-defined prompts categorized by theme, used to provide users with inspiration for generating creative text.
|
18 |
SAMPLE_PROMPTS = {
|
19 |
'π Dramatic Monologue (Stranded Astronaut)':
|
20 |
+
'Write a short dramatic monologue from a lone astronaut stranded on Mars, speaking to '
|
21 |
+
'mission control for the last time. The tone should be reflective and filled with awe, conveying '
|
22 |
+
'resignation and finality. Describe the Martian landscape and their thoughts in a way that '
|
23 |
+
'would evoke emotion and depth in speech synthesis.',
|
24 |
|
25 |
'π Poetic Sonnet (The Passage of Time)':
|
26 |
+
'Compose a concise sonnet about the passage of time, using vivid imagery and a flowing, '
|
27 |
+
'melodic rhythm. The poem should evoke the contrast between fleeting moments and eternity, '
|
28 |
+
'capturing both beauty and melancholy, with natural pacing for speech delivery.',
|
29 |
|
30 |
"π± Whimsical Children's Story (Talking Cat)":
|
31 |
+
'Tell a short, whimsical bedtime story about a mischievous talking cat who sneaks into a grand '
|
32 |
+
'wizardβs library at night and accidentally casts a spell that brings the books to life. Keep the '
|
33 |
+
'tone playful and filled with wonder, ensuring the language flows smoothly for expressive TTS.',
|
34 |
|
35 |
'π₯ Intense Speech (Freedom & Justice)':
|
36 |
+
'Write a powerful, impassioned speech from a rebel leader rallying their people against a '
|
37 |
+
'tyrant. The speech should be urgent, filled with conviction, and call for freedom and justice, '
|
38 |
+
'making sure the emotional intensity is evident in the phrasing for speech synthesis.',
|
39 |
|
40 |
'π» Mysterious Horror Scene (Haunted Lighthouse)':
|
41 |
+
'Describe a chilling ghostly encounter in an abandoned lighthouse on a foggy night. The '
|
42 |
+
'protagonist, alone and cold, hears whispers from the shadows, telling them secrets they were '
|
43 |
+
'never meant to know. Use language that builds suspense and tension, ensuring it sounds '
|
44 |
+
'haunting and engaging when spoken aloud.'
|
45 |
}
|
src/integrations/anthropic_api.py
CHANGED
@@ -42,23 +42,23 @@ class AnthropicConfig:
|
|
42 |
api_key: str = validate_env_var('ANTHROPIC_API_KEY')
|
43 |
model: ModelParam = 'claude-3-5-sonnet-latest' # Valid predefined model
|
44 |
max_tokens: int = 256 # Max tokens for API response
|
45 |
-
system_prompt: str = """You are
|
46 |
|
47 |
-
Your task is to
|
48 |
1. Short stories,
|
49 |
2. Poems,
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
-
|
54 |
-
-
|
55 |
-
-
|
56 |
-
|
57 |
-
|
58 |
-
-
|
59 |
-
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
def __post_init__(self):
|
64 |
# Validate that required attributes are set
|
|
|
42 |
api_key: str = validate_env_var('ANTHROPIC_API_KEY')
|
43 |
model: ModelParam = 'claude-3-5-sonnet-latest' # Valid predefined model
|
44 |
max_tokens: int = 256 # Max tokens for API response
|
45 |
+
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.
|
46 |
|
47 |
+
Your task is to generate:
|
48 |
1. Short stories,
|
49 |
2. Poems,
|
50 |
+
2. Or other creative written outputs based on the user's prompt.
|
51 |
+
|
52 |
+
Guidelines for your responses:
|
53 |
+
- 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.
|
54 |
+
- Tone and Style: Tailor your tone and style to the request. For instance:
|
55 |
+
- If the request is for a poem, write with rhythm, flow, and creative imagery.
|
56 |
+
- For a short story, provide a clear narrative arc with vivid descriptions, ensuring a compelling beginning, middle, and end.
|
57 |
+
- Conciseness: Ensure responses are under {max_tokens} tokens, focusing on impactful brevity. Keep sentences clear and direct without unnecessary elaboration.
|
58 |
+
- Suitability: Responses should be suitable for a broad audience, avoiding any controversial or sensitive content.
|
59 |
+
- 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.
|
60 |
+
|
61 |
+
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."""
|
62 |
|
63 |
def __post_init__(self):
|
64 |
# Validate that required attributes are set
|