Skip to content

Commit fd775eb

Browse files
committed
minor #94 [AiBundle][McpBundle] Upgrade bundle structure (yceruto)
This PR was squashed before being merged into the main branch. Discussion ---------- [AiBundle][McpBundle] Upgrade bundle structure | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | Fix #91 | License | MIT This pull request introduces significant changes to the configuration system for AI-related bundles. It replaces the `Configuration.php` files with new `options.php` files, streamlining the definition of configuration options. Additionally, it removes exclusions from PHPStan analysis for the deleted `Configuration.php` files. ### Configuration System Overhaul: * [`src/ai-bundle/config/options.php`](diffhunk://#diff-cc69af4e9e9e5b26760c9b97f61ea6557fa5545e06d89c17eb8e95c3475e10d9R1-R211): Introduced a new configuration file to define options for AI platforms, agents, stores, and indexers. This replaces the previous `Configuration.php` file with a more concise and flexible structure. * [`src/mcp-bundle/config/options.php`](diffhunk://#diff-1a31327f5d505b06684dbd1329edca53f16fe3f3535d3ed7cb3a31d6a5f9044dR1-R65): Added a new configuration file for MCP bundle options, including client transport settings and application metadata. ### Removal of Legacy Files: * [`src/ai-bundle/src/DependencyInjection/Configuration.php`](diffhunk://#diff-6b3b818564647842e4bf70729631c74910a4bdd62890e2acecf07428978ac087L1-L225): Removed the old configuration file that defined options for AI platforms, agents, stores, and indexers. Its functionality has been replaced by the new `options.php` file. ### PHPStan Analysis Updates: * [`src/ai-bundle/phpstan.dist.neon`](diffhunk://#diff-b99fef75a571df1766ed883ed6618ff528a41b65f4748dd58588e7968610c226L5-L7): Removed the exclusion of `Configuration.php` from PHPStan analysis, as the file has been deleted. * [`src/mcp-bundle/phpstan.dist.neon`](diffhunk://#diff-b99fef75a571df1766ed883ed6618ff528a41b65f4748dd58588e7968610c226L5-L7): Similarly, removed the exclusion of `Configuration.php` from PHPStan analysis for the MCP bundle. Commits ------- e61d72d [AiBundle][McpBundle] Upgrade bundle structure
2 parents 7a0fb4f + e61d72d commit fd775eb

File tree

15 files changed

+817
-879
lines changed

15 files changed

+817
-879
lines changed

src/ai-bundle/config/options.php

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Config\Definition\Configurator;
13+
14+
use Symfony\AI\Platform\PlatformInterface;
15+
use Symfony\AI\Store\StoreInterface;
16+
17+
return static function (DefinitionConfigurator $configurator): void {
18+
$configurator->rootNode()
19+
->children()
20+
->arrayNode('platform')
21+
->children()
22+
->arrayNode('anthropic')
23+
->children()
24+
->scalarNode('api_key')->isRequired()->end()
25+
->scalarNode('version')->defaultNull()->end()
26+
->end()
27+
->end()
28+
->arrayNode('azure')
29+
->normalizeKeys(false)
30+
->useAttributeAsKey('name')
31+
->arrayPrototype()
32+
->children()
33+
->scalarNode('api_key')->isRequired()->end()
34+
->scalarNode('base_url')->isRequired()->end()
35+
->scalarNode('deployment')->isRequired()->end()
36+
->scalarNode('api_version')->info('The used API version')->end()
37+
->end()
38+
->end()
39+
->end()
40+
->arrayNode('google')
41+
->children()
42+
->scalarNode('api_key')->isRequired()->end()
43+
->end()
44+
->end()
45+
->arrayNode('openai')
46+
->children()
47+
->scalarNode('api_key')->isRequired()->end()
48+
->end()
49+
->end()
50+
->arrayNode('mistral')
51+
->children()
52+
->scalarNode('api_key')->isRequired()->end()
53+
->end()
54+
->end()
55+
->arrayNode('openrouter')
56+
->children()
57+
->scalarNode('api_key')->isRequired()->end()
58+
->end()
59+
->end()
60+
->end()
61+
->end()
62+
->arrayNode('agent')
63+
->normalizeKeys(false)
64+
->useAttributeAsKey('name')
65+
->arrayPrototype()
66+
->children()
67+
->scalarNode('platform')
68+
->info('Service name of platform')
69+
->defaultValue(PlatformInterface::class)
70+
->end()
71+
->arrayNode('model')
72+
->children()
73+
->scalarNode('name')->isRequired()->end()
74+
->scalarNode('version')->defaultNull()->end()
75+
->arrayNode('options')
76+
->scalarPrototype()->end()
77+
->end()
78+
->end()
79+
->end()
80+
->booleanNode('structured_output')->defaultTrue()->end()
81+
->scalarNode('system_prompt')
82+
->validate()
83+
->ifTrue(fn ($v) => null !== $v && '' === trim($v))
84+
->thenInvalid('The default system prompt must not be an empty string')
85+
->end()
86+
->defaultNull()
87+
->info('The default system prompt of the agent')
88+
->end()
89+
->booleanNode('include_tools')
90+
->info('Include tool definitions at the end of the system prompt')
91+
->defaultFalse()
92+
->end()
93+
->arrayNode('tools')
94+
->addDefaultsIfNotSet()
95+
->treatFalseLike(['enabled' => false])
96+
->treatTrueLike(['enabled' => true])
97+
->treatNullLike(['enabled' => true])
98+
->beforeNormalization()
99+
->ifArray()
100+
->then(function (array $v) {
101+
return [
102+
'enabled' => $v['enabled'] ?? true,
103+
'services' => $v['services'] ?? $v,
104+
];
105+
})
106+
->end()
107+
->children()
108+
->booleanNode('enabled')->defaultTrue()->end()
109+
->arrayNode('services')
110+
->arrayPrototype()
111+
->children()
112+
->scalarNode('service')->isRequired()->end()
113+
->scalarNode('name')->end()
114+
->scalarNode('description')->end()
115+
->scalarNode('method')->end()
116+
->booleanNode('is_agent')->defaultFalse()->end()
117+
->end()
118+
->beforeNormalization()
119+
->ifString()
120+
->then(function (string $v) {
121+
return ['service' => $v];
122+
})
123+
->end()
124+
->end()
125+
->end()
126+
->end()
127+
->end()
128+
->booleanNode('fault_tolerant_toolbox')->defaultTrue()->end()
129+
->end()
130+
->end()
131+
->end()
132+
->arrayNode('store')
133+
->children()
134+
->arrayNode('azure_search')
135+
->normalizeKeys(false)
136+
->useAttributeAsKey('name')
137+
->arrayPrototype()
138+
->children()
139+
->scalarNode('endpoint')->isRequired()->end()
140+
->scalarNode('api_key')->isRequired()->end()
141+
->scalarNode('index_name')->isRequired()->end()
142+
->scalarNode('api_version')->isRequired()->end()
143+
->scalarNode('vector_field')->end()
144+
->end()
145+
->end()
146+
->end()
147+
->arrayNode('chroma_db')
148+
->normalizeKeys(false)
149+
->useAttributeAsKey('name')
150+
->arrayPrototype()
151+
->children()
152+
->scalarNode('collection')->isRequired()->end()
153+
->end()
154+
->end()
155+
->end()
156+
->arrayNode('mongodb')
157+
->normalizeKeys(false)
158+
->useAttributeAsKey('name')
159+
->arrayPrototype()
160+
->children()
161+
->scalarNode('database')->isRequired()->end()
162+
->scalarNode('collection')->isRequired()->end()
163+
->scalarNode('index_name')->isRequired()->end()
164+
->scalarNode('vector_field')->end()
165+
->booleanNode('bulk_write')->end()
166+
->end()
167+
->end()
168+
->end()
169+
->arrayNode('pinecone')
170+
->normalizeKeys(false)
171+
->useAttributeAsKey('name')
172+
->arrayPrototype()
173+
->children()
174+
->scalarNode('namespace')->end()
175+
->arrayNode('filter')
176+
->scalarPrototype()->end()
177+
->end()
178+
->integerNode('top_k')->end()
179+
->end()
180+
->end()
181+
->end()
182+
->end()
183+
->end()
184+
->arrayNode('indexer')
185+
->normalizeKeys(false)
186+
->useAttributeAsKey('name')
187+
->arrayPrototype()
188+
->children()
189+
->scalarNode('store')
190+
->info('Service name of store')
191+
->defaultValue(StoreInterface::class)
192+
->end()
193+
->scalarNode('platform')
194+
->info('Service name of platform')
195+
->defaultValue(PlatformInterface::class)
196+
->end()
197+
->arrayNode('model')
198+
->children()
199+
->scalarNode('name')->isRequired()->end()
200+
->scalarNode('version')->defaultNull()->end()
201+
->arrayNode('options')
202+
->scalarPrototype()->end()
203+
->end()
204+
->end()
205+
->end()
206+
->end()
207+
->end()
208+
->end()
209+
->end()
210+
;
211+
};

src/ai-bundle/phpstan.dist.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ parameters:
22
level: 6
33
paths:
44
- src/
5-
excludePaths:
6-
analyse:
7-
- src/DependencyInjection/Configuration.php

0 commit comments

Comments
 (0)