Files
letta-server/letta/schemas/tool_rule.py
2024-12-10 16:10:34 -08:00

41 lines
1.0 KiB
Python

from typing import List, Union
from pydantic import Field
from letta.schemas.enums import ToolRuleType
from letta.schemas.letta_base import LettaBase
class BaseToolRule(LettaBase):
__id_prefix__ = "tool_rule"
tool_name: str = Field(..., description="The name of the tool. Must exist in the database for the user's organization.")
type: ToolRuleType
class ChildToolRule(BaseToolRule):
"""
A ToolRule represents a tool that can be invoked by the agent.
"""
type: ToolRuleType = ToolRuleType.constrain_child_tools
children: List[str] = Field(..., description="The children tools that can be invoked.")
class InitToolRule(BaseToolRule):
"""
Represents the initial tool rule configuration.
"""
type: ToolRuleType = ToolRuleType.run_first
class TerminalToolRule(BaseToolRule):
"""
Represents a terminal tool rule configuration where if this tool gets called, it must end the agent loop.
"""
type: ToolRuleType = ToolRuleType.exit_loop
ToolRule = Union[ChildToolRule, InitToolRule, TerminalToolRule]