use App\AiAgents\WeatherAgent;// Create an instance for a specific user or chat session$agent = WeatherAgent::for('user-123');// Get a response$response = $agent->respond('What\'s the weather like in Boston?');echo $response; // "The weather in Boston is currently..."
Tools allow your agent to perform actions and access external data:
Copy
namespace App\AiAgents;use LarAgent\Agent;use LarAgent\Attributes\Tool;class WeatherAgent extends Agent{ // ... other properties #[Tool('Get the current weather in a given location')] public function getCurrentWeather($location, $unit = 'celsius') { // Call a weather API or service return "The weather in {$location} is 22 degrees {$unit}."; }}