1namespace App\Ai\Tools;
2
3use Illuminate\Contracts\JsonSchema\JsonSchema;
4use Laravel\Ai\Contracts\Tool;
5use Laravel\Ai\Tools\Request;
6use Stringable;
7
8class RandomNumberGenerator implements Tool
9{
10 /**
11 * Get the description of the tool's purpose.
12 */
13 public function description(): Stringable|string
14 {
15 return 'This tool may be used to generate cryptographically secure random numbers.';
16 }
17
18 /**
19 * Execute the tool.
20 */
21 public function handle(Request $request): Stringable|string
22 {
23 return (string) random_int($request['min'], $request['max']);
24 }
25
26 /**
27 * Get the tool's schema definition.
28 */
29 public function schema(JsonSchema $schema): array
30 {
31 return [
32 'min' => $schema->integer()->min(0)->required(),
33 'max' => $schema->integer()->required(),
34 ];
35 }
36}
namespace App\Ai\Tools;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Ai\Contracts\Tool;
use Laravel\Ai\Tools\Request;
use Stringable;
class RandomNumberGenerator implements Tool
{
/**
* Get the description of the tool's purpose.
*/
public function description(): Stringable|string
{
return 'This tool may be used to generate cryptographically secure random numbers.';
}
/**
* Execute the tool.
*/
public function handle(Request $request): Stringable|string
{
return (string) random_int($request['min'], $request['max']);
}
/**
* Get the tool's schema definition.
*/
public function schema(JsonSchema $schema): array
{
return [
'min' => $schema->integer()->min(0)->required(),
'max' => $schema->integer()->required(),
];
}
}