zach commited on
Commit
5adc4ce
Β·
1 Parent(s): 5a007ca

Update claude system prompt, sample prompts, and max prompt input limit

Browse files
Files changed (2) hide show
  1. src/constants.py +18 -14
  2. 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 = 300
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
- 'speaking to mission control for the last time. The tone should be reflective, '
22
- 'filled with awe and resignation as they describe the Martian landscape and their final thoughts.',
 
23
 
24
  'πŸ“œ Poetic Sonnet (The Passage of Time)':
25
- 'Compose a sonnet about the passage of time, using vivid imagery and a flowing, melodic rhythm. '
26
- 'The poem should contrast fleeting moments with eternity, capturing both beauty and melancholy.',
 
27
 
28
  "🐱 Whimsical Children's Story (Talking Cat)":
29
- 'Tell a short bedtime story about a mischievous talking cat who sneaks into a grand wizard’s library '
30
- 'at night and accidentally casts a spell that brings the books to life. '
31
- 'Make the tone playful, whimsical, and filled with wonder.',
32
 
33
  'πŸ”₯ Intense Speech (Freedom & Justice)':
34
- 'Write a powerful speech delivered by a rebel leader rallying their people against a tyrant. '
35
- 'The speech should be passionate, filled with urgency and conviction, calling for freedom and justice.',
 
36
 
37
  'πŸ‘» Mysterious Horror Scene (Haunted Lighthouse)':
38
- 'Describe a chilling ghostly encounter in an abandoned lighthouse on a foggy night. '
39
- 'The protagonist, alone and cold, begins hearing whispers from the shadows, '
40
- 'telling them secrets they were never meant to know.'
 
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 a highly creative and articulate assistant specialized in generating vivid, engaging, and well-written content.
46
 
47
- Your task is to respond to user prompts by creating:
48
  1. Short stories,
49
  2. Poems,
50
- 3. Or other creative written outputs.
51
-
52
- Ensure that your responses are:
53
- - Imaginative and original,
54
- - Coherent and well-structured,
55
- - Suitable for a wide audience, avoiding controversial or sensitive topics.
56
-
57
- When writing, tailor your tone and style to match the user's request. For example:
58
- - If the user requests a poem, provide creative and rhythmic verse.
59
- - If the user requests a short story, ensure a clear beginning, middle, and end with compelling details.
60
-
61
- Always keep your responses concise, unless explicitly instructed to elaborate."""
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