44
55namespace PhpLlm \LlmChain \Platform \Bridge \Anthropic ;
66
7- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \AssistantMessageNormalizer ;
8- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \DocumentNormalizer ;
9- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \DocumentUrlNormalizer ;
10- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \ImageNormalizer ;
11- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \ImageUrlNormalizer ;
12- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \MessageBagNormalizer ;
13- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \ToolCallMessageNormalizer ;
14- use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \ToolNormalizer ;
7+ use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Contract \AnthropicSet ;
158use PhpLlm \LlmChain \Platform \Contract ;
9+ use PhpLlm \LlmChain \Platform \ContractInterface ;
1610use PhpLlm \LlmChain \Platform \Platform ;
1711use Symfony \Component \HttpClient \EventSourceHttpClient ;
1812use Symfony \Contracts \HttpClient \HttpClientInterface ;
@@ -27,22 +21,14 @@ public static function create(
2721 string $ apiKey ,
2822 string $ version = '2023-06-01 ' ,
2923 ?HttpClientInterface $ httpClient = null ,
24+ ?ContractInterface $ contract = null ,
3025 ): Platform {
3126 $ httpClient = $ httpClient instanceof EventSourceHttpClient ? $ httpClient : new EventSourceHttpClient ($ httpClient );
3227
3328 return new Platform (
3429 [new ModelClient ($ httpClient , $ apiKey , $ version )],
3530 [new ResponseConverter ()],
36- Contract::create (
37- new AssistantMessageNormalizer (),
38- new DocumentNormalizer (),
39- new DocumentUrlNormalizer (),
40- new ImageNormalizer (),
41- new ImageUrlNormalizer (),
42- new MessageBagNormalizer (),
43- new ToolCallMessageNormalizer (),
44- new ToolNormalizer (),
45- )
31+ $ contract ?? Contract::create (...AnthropicSet::get ()),
4632 );
4733 }
4834}
0 commit comments