Skip to content

weather

weather

Native, parameterized weather tool backed by OpenWeatherMap.

Classes

WeatherTool

WeatherTool(*, api_key: str | None = None, connector: WeatherConnector | None = None, config: Any = None)

Bases: BaseTool

Fetch current or forecast weather for a dynamic location.

Source code in src/openjarvis/tools/weather.py
def __init__(
    self,
    *,
    api_key: str | None = None,
    connector: weather_connector.WeatherConnector | None = None,
    config: Any = None,
) -> None:
    self._api_key = (api_key or "").strip() or None
    self._connector = connector or weather_connector.WeatherConnector()
    self._config_error = False
    if config is None:
        try:
            from openjarvis.core.config import load_config

            config = load_config().tools.weather
        except Exception:
            self._config_error = True
            config = None
    self._provider = str(getattr(config, "provider", "openweathermap") or "")
    self._default_location = str(
        getattr(config, "default_location", "") or ""
    ).strip()
    self._default_units = str(getattr(config, "units", "metric") or "").lower()
    self._default_language = str(getattr(config, "lang", "en") or "").lower()
Functions
is_configured
is_configured() -> bool

Return credential presence without exposing the credential value.

Source code in src/openjarvis/tools/weather.py
def is_configured(self) -> bool:
    """Return credential presence without exposing the credential value."""
    return self._resolve_api_key() is not None

Functions