-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathClaudeCodeModelMetadataDirectory.php
More file actions
81 lines (71 loc) · 2.6 KB
/
Copy pathClaudeCodeModelMetadataDirectory.php
File metadata and controls
81 lines (71 loc) · 2.6 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
declare(strict_types=1);
namespace ExtraChill\ClaudeCodeAiProvider\Provider;
use WordPress\AiClient\Common\Exception\InvalidArgumentException;
use WordPress\AiClient\Messages\Enums\ModalityEnum;
use WordPress\AiClient\Providers\Contracts\ModelMetadataDirectoryInterface;
use WordPress\AiClient\Providers\Models\DTO\ModelMetadata;
use WordPress\AiClient\Providers\Models\DTO\SupportedOption;
use WordPress\AiClient\Providers\Models\Enums\CapabilityEnum;
use WordPress\AiClient\Providers\Models\Enums\OptionEnum;
/**
* Model metadata directory for Claude Code models.
*/
class ClaudeCodeModelMetadataDirectory implements ModelMetadataDirectoryInterface
{
/**
* {@inheritDoc}
*/
public function listModelMetadata(): array
{
return array_values($this->getModelMap());
}
/**
* {@inheritDoc}
*/
public function hasModelMetadata(string $modelId): bool
{
return isset($this->getModelMap()[$modelId]);
}
/**
* {@inheritDoc}
*/
public function getModelMetadata(string $modelId): ModelMetadata
{
$models = $this->getModelMap();
if (!isset($models[$modelId])) {
throw new InvalidArgumentException('No Claude Code model with the requested ID was found.');
}
return $models[$modelId];
}
/**
* Gets the supported Claude Code model map.
*
* @return array<string, ModelMetadata> Model metadata keyed by ID.
*/
private function getModelMap(): array
{
$options = [
new SupportedOption(OptionEnum::systemInstruction()),
new SupportedOption(OptionEnum::maxTokens()),
new SupportedOption(OptionEnum::temperature()),
new SupportedOption(OptionEnum::topP()),
new SupportedOption(OptionEnum::outputMimeType(), ['text/plain', 'application/json']),
new SupportedOption(OptionEnum::outputSchema()),
new SupportedOption(OptionEnum::functionDeclarations()),
new SupportedOption(OptionEnum::customOptions()),
new SupportedOption(OptionEnum::inputModalities(), [[ModalityEnum::text()]]),
new SupportedOption(OptionEnum::outputModalities(), [[ModalityEnum::text()]]),
];
$models = [];
foreach (['claude-opus-4-8', 'claude-opus-4-7', 'claude-sonnet-4-6', 'claude-haiku-4-5'] as $modelId) {
$models[$modelId] = new ModelMetadata(
$modelId,
$modelId,
[CapabilityEnum::textGeneration(), CapabilityEnum::chatHistory()],
$options
);
}
return $models;
}
}