Skip to content

Commit eab3d41

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 084b785 + 7a7996b commit eab3d41

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/Api/OpenAI/Request/ToolDefinition.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Hyperf\Odin\Api\OpenAI\Request;
1414

15+
use Closure;
1516
use Hyperf\Contract\Arrayable;
1617
use InvalidArgumentException;
1718

@@ -26,15 +27,16 @@ class ToolDefinition implements Arrayable
2627
/**
2728
* @var callable[]
2829
*/
29-
protected array $toolHandler = [];
30+
protected array|Closure $toolHandler = [];
31+
3032
protected array $examples;
3133

3234
public function __construct(
3335
string $name,
3436
string $description = '',
3537
?ToolParameters $parameters = null,
3638
array $examples = [],
37-
callable|array $toolHandler = [],
39+
array|callable|Closure $toolHandler = [],
3840
) {
3941
$this->name = $name;
4042
$this->description = $description;
@@ -51,7 +53,7 @@ public function toArray(): array
5153
'name' => $this->getName(),
5254
'description' => $this->getDescription(),
5355
'parameters' => $this->getParameters()?->toArray(),
54-
]
56+
],
5557
];
5658
}
5759

@@ -64,16 +66,16 @@ public function toArrayWithExamples(): array
6466
'description' => $this->getDescription(),
6567
'parameters' => $this->getParameters()?->toArray(),
6668
'examples' => $this->getExamples(),
67-
]
69+
],
6870
];
6971
}
7072

71-
public function getToolHandler(): array
73+
public function getToolHandler(): array|callable|Closure
7274
{
7375
return $this->toolHandler;
7476
}
7577

76-
public function setToolHandler(array|callable $toolHandler): static
78+
public function setToolHandler(array|callable|Closure $toolHandler): static
7779
{
7880
if (! is_callable($toolHandler)) {
7981
throw new InvalidArgumentException('Tool handler must be callable.');
@@ -87,7 +89,7 @@ public function getName(): string
8789
return $this->name;
8890
}
8991

90-
public function setName(string $name)
92+
public function setName(string $name): static
9193
{
9294
$this->name = $name;
9395
return $this;
@@ -120,7 +122,7 @@ public function getExamples(): array
120122
return $this->examples;
121123
}
122124

123-
public function setExamples(array $examples)
125+
public function setExamples(array $examples): static
124126
{
125127
$this->examples = $examples;
126128
return $this;

0 commit comments

Comments
 (0)