PluginProbe
ZIP AI – AI Website Builder & AI Agent (Beta) / 0.0.8
ZIP AI – AI Website Builder & AI Agent (Beta) v0.0.8
0.0.10 0.0.9 trunk 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8
zip-ai / lib / php-mcp-schema / src / Client / Sampling / DTO / ModelHint.php

ModelHint.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/php-mcp-schema/src/Client/Sampling/DTO/ModelHint.php

92 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Sampling\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Hints to use for model selection.
12 *
13 * Keys not declared here are currently left unspecified by the spec and are up
14 * to the client to interpret.
15 *
16 * @since 2024-11-05
17 *
18 * @mcp-domain Client
19 * @mcp-subdomain Sampling
20 * @mcp-version 2025-11-25
21 */
22 class ModelHint extends AbstractDataTransferObject
23 {
24 use ValidatesRequiredFields;
25
26 /**
27 * A hint for a model name.
28 *
29 * The client SHOULD treat this as a substring of a model name; for example:
30 * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
31 * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
32 * - `claude` should match any Claude model
33 *
34 * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:
35 * - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
36 *
37 * @since 2024-11-05
38 *
39 * @var string|null
40 */
41 protected ?string $name;
42
43 /**
44 * @param string|null $name @since 2024-11-05
45 */
46 public function __construct(
47 ?string $name = null
48 ) {
49 $this->name = $name;
50 }
51
52 /**
53 * Creates an instance from an array.
54 *
55 * @param array{
56 * name?: string|null
57 * } $data
58 * @phpstan-param array<string, mixed> $data
59 * @return self
60 */
61 public static function fromArray(array $data): self
62 {
63 return new self(
64 self::asStringOrNull($data['name'] ?? null)
65 );
66 }
67
68 /**
69 * Converts the instance to an array.
70 *
71 * @return array<string, mixed>
72 */
73 public function toArray(): array
74 {
75 $result = [];
76
77 if ($this->name !== null) {
78 $result['name'] = $this->name;
79 }
80
81 return $result;
82 }
83
84 /**
85 * @return string|null
86 */
87 public function getName(): ?string
88 {
89 return $this->name;
90 }
91 }
92