Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

All notable changes to this project will be documented in this file.

## v1.10.0 - 2026-03-19

### Added

- Laravel 13 support (`laravel/framework` ^13.0, `orchestra/testbench` ^11.0)
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"php": "^8.2",
"laravel/framework": "^11.0|^12.0",
"laravel/framework": "^11.0|^12.0|^13.0",
"aws/aws-sdk-php": "^3.339",
"prism-php/prism": ">=0.99.7"
},
Expand All @@ -41,7 +41,7 @@
"phpstan/phpstan-deprecation-rules": "^2.0",
"rector/rector": "2.2.14",
"projektgopher/whisky": "^0.7.0",
"orchestra/testbench": "^9.4",
"orchestra/testbench": "^9.4|^10.0|^11.0",
"mockery/mockery": "^1.6",
"symplify/rule-doc-generator-contracts": "^11.2",
"phpstan/phpdoc-parser": "^2.0",
Expand Down
8 changes: 4 additions & 4 deletions src/Schemas/Anthropic/Maps/ToolChoiceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
class ToolChoiceMap
{
/**
* @return array<string, mixed>|string|null
* @return array<string, mixed>|null
*/
public static function map(string|ToolChoice|null $toolChoice): string|array|null
public static function map(string|ToolChoice|null $toolChoice): ?array
{
if (is_null($toolChoice)) {
return null;
Expand All @@ -30,8 +30,8 @@ public static function map(string|ToolChoice|null $toolChoice): string|array|nul
}

return match ($toolChoice) {
ToolChoice::Auto => 'auto',
ToolChoice::Any => 'any',
ToolChoice::Auto => ['type' => 'auto'],
ToolChoice::Any => ['type' => 'any'],
};

}
Expand Down
4 changes: 1 addition & 3 deletions src/Schemas/Converse/Maps/ToolChoiceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public static function map(string|ToolChoice|null $toolChoice): string|array|nul
}

return [
'tool' => [
($toolChoice === ToolChoice::Auto ? 'auto' : 'any') => [],
],
($toolChoice === ToolChoice::Auto ? 'auto' : 'any') => new \stdClass,
];
}
}
35 changes: 35 additions & 0 deletions tests/Schemas/Anthropic/Maps/ToolChoiceMapTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Tests\Schemas\Anthropic\Maps;

use InvalidArgumentException;
use Prism\Bedrock\Schemas\Anthropic\Maps\ToolChoiceMap;
use Prism\Prism\Enums\ToolChoice;

it('returns null when tool choice is null', function (): void {
expect(ToolChoiceMap::map(null))->toBeNull();
});

it('maps a specific tool correctly', function (): void {
expect(ToolChoiceMap::map('search'))
->toBe([
'type' => 'tool',
'name' => 'search',
]);
});

it('maps auto tool correctly', function (): void {
expect(ToolChoiceMap::map(ToolChoice::Auto))
->toBe(['type' => 'auto']);
});

it('maps any tool correctly', function (): void {
expect(ToolChoiceMap::map(ToolChoice::Any))
->toBe(['type' => 'any']);
});

it('throws exception for invalid tool choice', function (): void {
ToolChoiceMap::map(ToolChoice::None);
})->throws(InvalidArgumentException::class, 'Invalid tool choice');
12 changes: 4 additions & 8 deletions tests/Schemas/Converse/Maps/ToolChoiceMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@

it('maps any tool correctly', function (): void {
expect(ToolChoiceMap::map(ToolChoice::Any))
->toBe([
'tool' => [
'any' => [],
],
->toEqual([
'any' => new \stdClass,
]);
});

it('maps auto tool correctly', function (): void {
expect(ToolChoiceMap::map(ToolChoice::Auto))
->toBe([
'tool' => [
'auto' => [],
],
->toEqual([
'auto' => new \stdClass,
]);
});