Skip to content

Tool schema

ToolBaseSchema

Bases: ABC, BaseModel

Base schema for a Tool used in LLM.

Source code in light_agents/schemas/tool_schema.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class ToolBaseSchema(ABC, BaseModel):
    """Base schema for a Tool used in LLM."""

    model_config = ConfigDict(extra="allow")
    name: str = Field(..., description="The name of the function")
    description: str = Field(
        ..., description="A brief description of what the function does"
    )
    json_response: Optional[bool] = Field(
        default=False, description="Flag to indicate if the response is a JSON"
    )
    required: Optional[List[str]] = Field(default=[], description="The required fields")

    @abstractmethod
    def run(self, *args: Any, **kwargs: Any) -> "ToolResponseSchema":
        """Python  function to be executed when the tool is called."""
        pass

run(*args, **kwargs) abstractmethod

Python function to be executed when the tool is called.

Source code in light_agents/schemas/tool_schema.py
20
21
22
23
@abstractmethod
def run(self, *args: Any, **kwargs: Any) -> "ToolResponseSchema":
    """Python  function to be executed when the tool is called."""
    pass

ToolResponseSchema

Bases: BaseModel

Base schema for a Tool response used by an LLM.

Source code in light_agents/schemas/tool_schema.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class ToolResponseSchema(BaseModel):
    """Base schema for a Tool response used by an LLM."""

    content: str
    """String content to be returned by the tool to the LLM.

     It can include any content or extra prompt to guide the LLM based on the
     tool's output.
     """

    external_fields: Optional[dict[str, Any]] = {}
    """External fields to be returned for the thread.

     Returns extra information and update thread fields based on
     the tool's output, without feeding the LLM with the content.
     Usefull for passing sensitive information to prevent prompt injection. 
     """

    is_error: Optional[bool] = False
    """Flag to indicate if the tool response is an error."""

content: str instance-attribute

String content to be returned by the tool to the LLM.

It can include any content or extra prompt to guide the LLM based on the tool's output.

external_fields: Optional[dict[str, Any]] = {} class-attribute instance-attribute

External fields to be returned for the thread.

Returns extra information and update thread fields based on the tool's output, without feeding the LLM with the content. Usefull for passing sensitive information to prevent prompt injection.

is_error: Optional[bool] = False class-attribute instance-attribute

Flag to indicate if the tool response is an error.