Skip to content

Commit d8c374e

Browse files
committed
minor #406 [AI Bundle] Remove unnecessary normalizeKeys(false) from options.php (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [AI Bundle] Remove unnecessary `normalizeKeys(false)` from `options.php` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | Fix #404 | License | MIT Commits ------- 46789a5 [AI Bundle] Remove unnecessary `normalizeKeys(false)` from `options.php`
2 parents de8db34 + 46789a5 commit d8c374e

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

src/ai-bundle/config/options.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
->end()
3030
->end()
3131
->arrayNode('azure')
32-
->normalizeKeys(false)
3332
->useAttributeAsKey('name')
3433
->arrayPrototype()
3534
->children()
@@ -95,7 +94,6 @@
9594
->end()
9695
->end()
9796
->arrayNode('agent')
98-
->normalizeKeys(false)
9997
->useAttributeAsKey('name')
10098
->arrayPrototype()
10199
->children()
@@ -175,7 +173,6 @@
175173
->arrayNode('store')
176174
->children()
177175
->arrayNode('azure_search')
178-
->normalizeKeys(false)
179176
->useAttributeAsKey('name')
180177
->arrayPrototype()
181178
->children()
@@ -188,7 +185,6 @@
188185
->end()
189186
->end()
190187
->arrayNode('cache')
191-
->normalizeKeys(false)
192188
->useAttributeAsKey('name')
193189
->arrayPrototype()
194190
->children()
@@ -199,7 +195,6 @@
199195
->end()
200196
->end()
201197
->arrayNode('chroma_db')
202-
->normalizeKeys(false)
203198
->useAttributeAsKey('name')
204199
->arrayPrototype()
205200
->children()
@@ -209,7 +204,6 @@
209204
->end()
210205
->end()
211206
->arrayNode('clickhouse')
212-
->normalizeKeys(false)
213207
->useAttributeAsKey('name')
214208
->arrayPrototype()
215209
->children()
@@ -225,7 +219,6 @@
225219
->end()
226220
->end()
227221
->arrayNode('meilisearch')
228-
->normalizeKeys(false)
229222
->useAttributeAsKey('name')
230223
->arrayPrototype()
231224
->children()
@@ -239,7 +232,6 @@
239232
->end()
240233
->end()
241234
->arrayNode('memory')
242-
->normalizeKeys(false)
243235
->useAttributeAsKey('name')
244236
->arrayPrototype()
245237
->children()
@@ -248,7 +240,6 @@
248240
->end()
249241
->end()
250242
->arrayNode('milvus')
251-
->normalizeKeys(false)
252243
->useAttributeAsKey('name')
253244
->arrayPrototype()
254245
->children()
@@ -263,7 +254,6 @@
263254
->end()
264255
->end()
265256
->arrayNode('mongodb')
266-
->normalizeKeys(false)
267257
->useAttributeAsKey('name')
268258
->arrayPrototype()
269259
->children()
@@ -277,7 +267,6 @@
277267
->end()
278268
->end()
279269
->arrayNode('neo4j')
280-
->normalizeKeys(false)
281270
->useAttributeAsKey('name')
282271
->arrayPrototype()
283272
->children()
@@ -295,7 +284,6 @@
295284
->end()
296285
->end()
297286
->arrayNode('pinecone')
298-
->normalizeKeys(false)
299287
->useAttributeAsKey('name')
300288
->arrayPrototype()
301289
->children()
@@ -309,7 +297,6 @@
309297
->end()
310298
->end()
311299
->arrayNode('qdrant')
312-
->normalizeKeys(false)
313300
->useAttributeAsKey('name')
314301
->arrayPrototype()
315302
->children()
@@ -322,7 +309,6 @@
322309
->end()
323310
->end()
324311
->arrayNode('surreal_db')
325-
->normalizeKeys(false)
326312
->useAttributeAsKey('name')
327313
->arrayPrototype()
328314
->children()
@@ -340,7 +326,6 @@
340326
->end()
341327
->end()
342328
->arrayNode('typesense')
343-
->normalizeKeys(false)
344329
->useAttributeAsKey('name')
345330
->arrayPrototype()
346331
->children()
@@ -355,7 +340,6 @@
355340
->end()
356341
->end()
357342
->arrayNode('indexer')
358-
->normalizeKeys(false)
359343
->useAttributeAsKey('name')
360344
->arrayPrototype()
361345
->children()

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,45 @@ public function testInMemoryStoreWithCustomStrategyCanBeConfigured()
264264
$this->assertSame('ai.store.distance_calculator.my_memory_store_with_custom_strategy', (string) $definition->getArgument(0));
265265
}
266266

267+
public function testConfigurationWithUseAttributeAsKeyWorksWithoutNormalizeKeys()
268+
{
269+
// Test that configurations using useAttributeAsKey work correctly
270+
// after removing redundant normalizeKeys(false) calls
271+
$container = $this->buildContainer([
272+
'ai' => [
273+
'platform' => [
274+
'azure' => [
275+
'Test_Instance-123' => [ // Mixed case and special chars in key
276+
'api_key' => 'test_key',
277+
'base_url' => 'https://test.openai.azure.com/',
278+
'deployment' => 'gpt-35-turbo',
279+
'api_version' => '2024-02-15-preview',
280+
],
281+
],
282+
],
283+
'agent' => [
284+
'My-Agent_Name.v2' => [ // Mixed case and special chars in key
285+
'model' => ['class' => 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'],
286+
],
287+
],
288+
'store' => [
289+
'mongodb' => [
290+
'Production_DB-v3' => [ // Mixed case and special chars in key
291+
'database' => 'test_db',
292+
'collection' => 'test_collection',
293+
'index_name' => 'test_index',
294+
],
295+
],
296+
],
297+
],
298+
]);
299+
300+
// Verify that the services are created with the exact key names
301+
$this->assertTrue($container->hasDefinition('ai.platform.azure.Test_Instance-123'));
302+
$this->assertTrue($container->hasDefinition('ai.agent.My-Agent_Name.v2'));
303+
$this->assertTrue($container->hasDefinition('ai.store.mongodb.Production_DB-v3'));
304+
}
305+
267306
private function buildContainer(array $configuration): ContainerBuilder
268307
{
269308
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)