Time to bring Fred to life! In this lesson, we'll create Fred's foundation - his personality, voice, and basic configuration.
Let's start by creating Fred's basic structure. Create a new file called fred.py
:
#!/usr/bin/env python3
"""
Fred - The Wikipedia Knowledge Bot
A friendly agent that can search Wikipedia for factual information.
Fred is curious, helpful, and loves sharing knowledge from Wikipedia.
"""
from signalwire_agents import AgentBase
from signalwire_agents.core.function_result import SwaigFunctionResult
class FredTheWikiBot(AgentBase):
"""Fred - Your friendly Wikipedia assistant"""
def __init__(self):
super().__init__(
name="Fred",
route="/fred"
)
What's happening here:
#!/usr/bin/env python3
- Makes the script executable on Unix systemsAgentBase
- the foundation class for all agentsSwaigFunctionResult
- used for returning function resultsname="Fred"
- The agent's identifierroute="/fred"
- The HTTP endpoint (accessible at http://localhost:3000/fred)Now let's give Fred his friendly personality using the Prompt Object Model (POM):
def __init__(self):
super().__init__(
name="Fred",
route="/fred"
)
# Set up Fred's personality using POM
self.prompt_add_section(
"Personality",
"You are Fred, a friendly and knowledgeable assistant who loves learning and sharing information from Wikipedia. You're enthusiastic about facts and always eager to help people discover new things."
)
# Define Fred's primary goal
self.prompt_add_section(
"Goal",
"Help users find reliable factual information by searching Wikipedia. Make learning fun and engaging."
)
# Add specific instructions for Fred's behavior
self.prompt_add_section(
"Instructions",
bullets=[
"Introduce yourself as Fred when greeting users",
"Use the search_wiki function whenever users ask about factual topics",
"Be enthusiastic about sharing knowledge",
"If Wikipedia doesn't have information, suggest alternative search terms",
"Make learning conversational and enjoyable",
"Add interesting context or follow-up questions to engage users"
]
)
POM Sections Explained:
Let's give Fred a voice! SignalWire supports multiple Text-to-Speech providers:
# Configure Fred's voice
self.add_language(
name="English",
code="en-US",
voice="rime.bolt", # A friendly, energetic voice for Fred
speech_fillers=[
"Hmm, let me think...",
"Oh, that's interesting...",
"Great question!",
"Let me see..."
]
)
Voice Configuration:
name
: Display name for the languagecode
: Language code (en-US for US English)voice
: TTS voice selectionprovider.voice_name
rime.bolt
uses Rime provider with the "bolt" voicespeech_fillers
: Phrases used while the AI is "thinking"# Other voice examples:
# "rime.spore" - Professional, clear
# "rime.marsh" - Deep, authoritative
# "rime.cove" - Warm, friendly
# "elevenlabs.rachel" - Natural, conversational
Now let's configure how Fred interacts during conversations:
# Set conversation parameters
self.set_params({
"ai_model": "gpt-4.1-nano", # The AI model to use
"wait_for_user": True, # Wait for user to speak first
"end_of_speech_timeout": 1000, # Milliseconds of silence before assuming speech ended
"ai_volume": 7, # Voice volume level (1-10)
"local_tz": "America/New_York" # Timezone for time-related functions
})
Parameter Breakdown:
ai_model
: Which OpenAI model to usegpt-4.1-nano
- Fast, efficientgpt-4-turbo
- More capablewait_for_user
: Whether to wait for user input or speak firstend_of_speech_timeout
: How long to wait during pausesai_volume
: Speech volume (1=quiet, 10=loud)local_tz
: Default timezone for the agent # Add some context about Fred
self.set_global_data({
"assistant_name": "Fred",
"specialty": "Wikipedia knowledge",
"personality_traits": ["friendly", "curious", "enthusiastic", "helpful"]
})
This data is available to the AI during conversations, helping maintain consistency.
Help the speech recognition system understand domain-specific terms:
# Add hints for better speech recognition
self.add_hints([
"Wikipedia",
"Fred",
"tell me about",
"what is",
"who is",
"search for",
"look up"
])
These hints improve accuracy when users say these phrases.
Here's Fred's complete basic structure so far:
#!/usr/bin/env python3
"""
Fred - The Wikipedia Knowledge Bot
A friendly agent that can search Wikipedia for factual information.
Fred is curious, helpful, and loves sharing knowledge from Wikipedia.
"""
from signalwire_agents import AgentBase
from signalwire_agents.core.function_result import SwaigFunctionResult
class FredTheWikiBot(AgentBase):
"""Fred - Your friendly Wikipedia assistant"""
def __init__(self):
super().__init__(
name="Fred",
route="/fred"
)
# Set up Fred's personality using POM
self.prompt_add_section(
"Personality",
"You are Fred, a friendly and knowledgeable assistant who loves learning and sharing information from Wikipedia. You're enthusiastic about facts and always eager to help people discover new things."
)
self.prompt_add_section(
"Goal",
"Help users find reliable factual information by searching Wikipedia. Make learning fun and engaging."
)
self.prompt_add_section(
"Instructions",
bullets=[
"Introduce yourself as Fred when greeting users",
"Use the search_wiki function whenever users ask about factual topics",
"Be enthusiastic about sharing knowledge",
"If Wikipedia doesn't have information, suggest alternative search terms",
"Make learning conversational and enjoyable",
"Add interesting context or follow-up questions to engage users"
]
)
# Configure Fred's voice
self.add_language(
name="English",
code="en-US",
voice="rime.bolt", # A friendly, energetic voice for Fred
speech_fillers=[
"Hmm, let me think...",
"Oh, that's interesting...",
"Great question!",
"Let me see..."
]
)
# Add hints for better speech recognition
self.add_hints([
"Wikipedia",
"Fred",
"tell me about",
"what is",
"who is",
"search for",
"look up"
])
# Set conversation parameters
self.set_params({
"ai_model": "gpt-4.1-nano",
"wait_for_user": True,
"end_of_speech_timeout": 1000,
"ai_volume": 7,
"local_tz": "America/New_York"
})
# Add some context about Fred
self.set_global_data({
"assistant_name": "Fred",
"specialty": "Wikipedia knowledge",
"personality_traits": ["friendly", "curious", "enthusiastic", "helpful"]
})
Add a simple main function to test:
def main():
"""Test Fred's basic structure"""
fred = FredTheWikiBot()
print(f"✅ Fred created successfully!")
print(f" Name: {fred.get_name()}")
print(f" Route: /fred")
print(f" Ready to add capabilities!")
if __name__ == "__main__":
main()
Run it:
python fred.py
Expected output:
✅ Fred created successfully!
Name: Fred
Route: /fred
Ready to add capabilities!
POM organizes your agent's instructions into logical sections:
Fred now has personality and voice, but he can't search Wikipedia yet. Let's add that capability!
➡️ Continue to Lesson 4: Adding the Wikipedia Search Skill
Progress Check:
← Previous: Environment Setup | Back to Overview | Next: Wikipedia Skill →