class: JordanPrice\Toolbox\Tools\Weather\WeatherTool
env vars: WEATHER_API_KEY
source: GitHub
WEATHER_API_KEY=your_api_key_here

Prism Integration

use JordanPrice\Toolbox\Tools\Weather\WeatherTool;
use EchoLabs\Prism\Prism;
use EchoLabs\Prism\Enums\Provider;
use EchoLabs\Prism\Enums\ToolChoice;

$weatherTool = new WeatherTool();

$prism = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
    ->withPrompt('What is the weather in London?')
    ->withTools([$weatherTool])  // Pass the tool instance
    ->toolChoice(ToolChoice::Any);

$response = $prism->generate();

Publish

Optionally, you can publish the configuration file to make modifications:
# Publish just this tool
php artisan toolbox:publish weather

# Or publish all tools
php artisan toolbox:publish
Add your Weather API key to your .env file:

Methods

__invoke

Get weather data for a location.
public function __invoke(string $location): string

Parameters

  • location (string): Location to get the weather for. Can be a city name, zipcode, IP address, or lat/lng coordinates. Example: “London”

Returns

  • string: Formatted weather information