forked from prism-php/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatToolMap.php
More file actions
33 lines (29 loc) · 909 Bytes
/
ChatToolMap.php
File metadata and controls
33 lines (29 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace Prism\Prism\Providers\OpenAI\Maps;
use Prism\Prism\Tool;
class ChatToolMap
{
/**
* @param Tool[] $tools
* @return array<string, mixed>
*/
public static function Map(array $tools): array
{
return array_map(fn (Tool $tool): array => array_filter([
'type' => 'function',
'function' => [
'name' => $tool->name(),
'description' => $tool->description(),
...count($tool->parameters()) ? [
'parameters' => [
'type' => 'object',
'properties' => $tool->parametersAsArray(),
'required' => $tool->requiredParameters(),
],
] : [],
],
'strict' => (bool) $tool->providerOptions('strict'),
]), $tools);
}
}