Skip to main content

Agent

The Agent base class serves as the foundation for creating custom agents. By inheriting from this class, you can define system prompts and register function tools.

Key Features:​

  • Custom instruction configuration
  • State management lifecycle hooks
  • Function tool registration

Example Implementation:​

from videosdk.agents import Agent, AgentState

class VoiceAgent(Agent):
def __init__(self):
super().__init__(
instructions="You are a helpful voice assistant that can answer questions and help with tasks.",
)
# Register custom tools
self.register_tools([self.get_horoscope])

@function_tool
async def get_horoscope(self, sign: str) -> dict:
"""Get today's horoscope for a given zodiac sign.

Args:
sign: The zodiac sign (e.g., Aries, Taurus, Gemini, etc.)

Returns:
dict: Contains the sign and horoscope text
"""
horoscopes = {
"Aries": "Today is your lucky day!",
"Taurus": "Focus on your goals today.",
"Gemini": "Communication will be important today.",
}
return {
"sign": sign,
"horoscope": horoscopes.get(sign, "The stars are aligned for you today!"),
}

Got a Question? Ask us on discord


Was this helpful?