Skip to content

Example

GetWeather

Bases: ToolBaseSchema

Get the weather for a specific location.

Source code in light_agents/example.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class GetWeather(ToolBaseSchema):
    """Get the weather for a specific location."""

    name: str = "get_weather"
    description: str = "Get the weather for a specific location."
    # required: list[str] = ["location"]
    location: str = Field(
        ..., description="The location to get the weather for."
    )

    def run(self, location: str) -> ToolResponseSchema:
        """Get the weather for a specific location."""
        return ToolResponseSchema(
            content=f"The weather for {location} is rainy and cold. The temperature will be 10 degrees Celsius with heavy rain. Don't forget to bring an umbrella and wear warm clothes.",  # noqa: E501
        )

run(location)

Get the weather for a specific location.

Source code in light_agents/example.py
26
27
28
29
30
def run(self, location: str) -> ToolResponseSchema:
    """Get the weather for a specific location."""
    return ToolResponseSchema(
        content=f"The weather for {location} is rainy and cold. The temperature will be 10 degrees Celsius with heavy rain. Don't forget to bring an umbrella and wear warm clothes.",  # noqa: E501
    )