@@ -33,44 +33,41 @@ class User {
3333// Let's build a set of custom configuration providers.
3434// You can use those examples to build your framework-specific providers.
3535
36+
3637class CustomConfigProvider implements CanProvideConfig
3738{
3839 public function getConfig (string $ group , ?string $ preset = '' ): array {
3940 return match ($ group ) {
40- 'http ' => $ this ->http () ?? [],
41- 'debug ' => $ this ->debug ()[$ preset ] ?? [],
42- 'llm ' => $ this ->llm () ?? [],
43- 'structured ' => $ this ->struct () ?? [],
41+ 'http ' => $ this ->http ($ preset ),
42+ 'debug ' => $ this ->debug ($ preset ),
43+ 'llm ' => $ this ->llm ($ preset ),
4444 default => [],
4545 };
4646 }
4747
48- private function llm () : array {
49- return [
50- 'apiUrl ' => 'https://api.deepseek.com ' ,
51- 'apiKey ' => Env::get ('DEEPSEEK_API_KEY ' ),
52- 'endpoint ' => '/chat/completions ' ,
53- 'defaultModel ' => 'deepseek-chat ' ,
54- 'defaultMaxTokens ' => 128 ,
55- 'driver ' => 'deepseek ' ,
56- // ...
57- ];
58- }
59-
60- private function http () : array {
61- return [
62- 'driver ' => 'symfony ' ,
63- 'connectTimeout ' => 10 ,
64- 'requestTimeout ' => 30 ,
65- 'idleTimeout ' => -1 ,
66- 'maxConcurrent ' => 5 ,
67- 'poolTimeout ' => 60 ,
68- 'failOnError ' => true ,
48+ private function http (?string $ preset ) : array {
49+ $ config = [
50+ 'default ' => 'symfony ' ,
51+ 'presets ' => [
52+ 'symfony ' => [
53+ 'driver ' => 'symfony ' ,
54+ 'connectTimeout ' => 10 ,
55+ 'requestTimeout ' => 30 ,
56+ 'idleTimeout ' => -1 ,
57+ 'maxConcurrent ' => 5 ,
58+ 'poolTimeout ' => 60 ,
59+ 'failOnError ' => true ,
60+ ]
61+ //
62+ ],
6963 ];
64+ $ default = $ config ['default ' ];
65+ $ preset = $ preset ?: $ default ;
66+ return $ config ['presets ' ][$ preset ] ?? $ config ['presets ' ][$ default ] ?? [];
7067 }
7168
72- private function debug (): array {
73- return [
69+ private function debug (? string $ preset ): array {
70+ $ data = [
7471 'off ' => [
7572 'httpEnabled ' => true ,
7673 ],
@@ -84,11 +81,31 @@ private function debug(): array {
8481 'httpResponseBody ' => true ,
8582 'httpResponseStream ' => true ,
8683 'httpResponseStreamByLine ' => true ,
87- ]
84+ ],
85+ // ...
86+ ];
87+ $ preset = $ preset ?: 'off ' ;
88+ return $ data [$ preset ] ?? $ data ['off ' ];
89+ }
90+
91+ private function llm (?string $ preset ): array {
92+ $ data = [
93+ 'deepseek ' => [
94+ 'apiUrl ' => 'https://api.deepseek.com ' ,
95+ 'apiKey ' => Env::get ('DEEPSEEK_API_KEY ' ),
96+ 'endpoint ' => '/chat/completions ' ,
97+ 'defaultModel ' => 'deepseek-chat ' ,
98+ 'defaultMaxTokens ' => 128 ,
99+ 'driver ' => 'deepseek ' ,
100+ 'httpClientPreset ' => 'symfony ' ,
101+ ],
102+ // ...
88103 ];
104+ $ preset = $ preset ?: 'deepseek ' ;
105+ return $ data [$ preset ] ?? $ data ['deepseek ' ];
89106 }
90107
91- private function struct (): array {
108+ private function struct (? string $ preset ): array {
92109 return [
93110 'outputMode ' => OutputMode::Tools,
94111 'useObjectReferences ' => true ,
@@ -120,6 +137,7 @@ private function struct(): array {
120137 ];
121138 }
122139}
140+
123141$ configProvider = new CustomConfigProvider ();
124142
125143$ customClient = (new HttpClientBuilder (
0 commit comments