Guides
Create your own AI Agent
How to create a custom Agent for your use case.
You can subclass a RespondAgent
to create a simple agent that can be passed into StreamingConversation
has the following interface:
Here’s one that responds with the same message no matter what is said to it:
class BrokenRecordAgentConfig(AgentConfig, type="agent_broken_record"):
message: str
class BrokenRecordAgent(RespondAgent[BrokenRecordAgentConfig]):
# is_interrupt is True when the human has just interrupted the bot's last response
def respond(
self, human_input, is_interrupt: bool = False
) -> tuple[Optional[str], bool]:
return self.agent_config.message
async def generate_response(
self, human_input, is_interrupt: bool = False
) -> AsyncGenerator[Tuple[str, bool], None]: # message and whether or not the message is interruptible
"""Returns a generator that yields the agent's response one sentence at a time."""
yield self.agent_config.message, False
See our other agent implementations for more guidance!