Skip to content

Commit

Permalink
feat: support array for ToolParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Jan 16, 2025
1 parent 64aebe5 commit 9506324
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Model/Completion/Tools/ToolParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@

public function __construct(
public string $name,
public string $type,
public string|array $type,
public ?string $description = null,
public ?array $enum = null,
public bool $required = false
) {
Assert::notEmpty($name);
Assert::oneOf($type, self::SUPPORTED_TYPES);
Assert::notEmpty($description);

match (\is_array($type)) {
true => Assert::allInArray($type, self::SUPPORTED_TYPES),
default => Assert::oneOf($type, self::SUPPORTED_TYPES)
};
}

public function definition(): array
Expand Down

0 comments on commit 9506324

Please sign in to comment.