Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 211 additions & 0 deletions src/ai-bundle/config/options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Config\Definition\Configurator;

use Symfony\AI\Platform\PlatformInterface;
use Symfony\AI\Store\StoreInterface;

return static function (DefinitionConfigurator $configurator): void {
$configurator->rootNode()
->children()
->arrayNode('platform')
->children()
->arrayNode('anthropic')
->children()
->scalarNode('api_key')->isRequired()->end()
->scalarNode('version')->defaultNull()->end()
->end()
->end()
->arrayNode('azure')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('api_key')->isRequired()->end()
->scalarNode('base_url')->isRequired()->end()
->scalarNode('deployment')->isRequired()->end()
->scalarNode('api_version')->info('The used API version')->end()
->end()
->end()
->end()
->arrayNode('google')
->children()
->scalarNode('api_key')->isRequired()->end()
->end()
->end()
->arrayNode('openai')
->children()
->scalarNode('api_key')->isRequired()->end()
->end()
->end()
->arrayNode('mistral')
->children()
->scalarNode('api_key')->isRequired()->end()
->end()
->end()
->arrayNode('openrouter')
->children()
->scalarNode('api_key')->isRequired()->end()
->end()
->end()
->end()
->end()
->arrayNode('agent')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('platform')
->info('Service name of platform')
->defaultValue(PlatformInterface::class)
->end()
->arrayNode('model')
->children()
->scalarNode('name')->isRequired()->end()
->scalarNode('version')->defaultNull()->end()
->arrayNode('options')
->scalarPrototype()->end()
->end()
->end()
->end()
->booleanNode('structured_output')->defaultTrue()->end()
->scalarNode('system_prompt')
->validate()
->ifTrue(fn ($v) => null !== $v && '' === trim($v))
->thenInvalid('The default system prompt must not be an empty string')
->end()
->defaultNull()
->info('The default system prompt of the agent')
->end()
->booleanNode('include_tools')
->info('Include tool definitions at the end of the system prompt')
->defaultFalse()
->end()
->arrayNode('tools')
->addDefaultsIfNotSet()
->treatFalseLike(['enabled' => false])
->treatTrueLike(['enabled' => true])
->treatNullLike(['enabled' => true])
->beforeNormalization()
->ifArray()
->then(function (array $v) {
return [
'enabled' => $v['enabled'] ?? true,
'services' => $v['services'] ?? $v,
];
})
->end()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->arrayNode('services')
->arrayPrototype()
->children()
->scalarNode('service')->isRequired()->end()
->scalarNode('name')->end()
->scalarNode('description')->end()
->scalarNode('method')->end()
->booleanNode('is_agent')->defaultFalse()->end()
->end()
->beforeNormalization()
->ifString()
->then(function (string $v) {
return ['service' => $v];
})
->end()
->end()
->end()
->end()
->end()
->booleanNode('fault_tolerant_toolbox')->defaultTrue()->end()
->end()
->end()
->end()
->arrayNode('store')
->children()
->arrayNode('azure_search')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('endpoint')->isRequired()->end()
->scalarNode('api_key')->isRequired()->end()
->scalarNode('index_name')->isRequired()->end()
->scalarNode('api_version')->isRequired()->end()
->scalarNode('vector_field')->end()
->end()
->end()
->end()
->arrayNode('chroma_db')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('collection')->isRequired()->end()
->end()
->end()
->end()
->arrayNode('mongodb')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('database')->isRequired()->end()
->scalarNode('collection')->isRequired()->end()
->scalarNode('index_name')->isRequired()->end()
->scalarNode('vector_field')->end()
->booleanNode('bulk_write')->end()
->end()
->end()
->end()
->arrayNode('pinecone')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('namespace')->end()
->arrayNode('filter')
->scalarPrototype()->end()
->end()
->integerNode('top_k')->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('indexer')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('store')
->info('Service name of store')
->defaultValue(StoreInterface::class)
->end()
->scalarNode('platform')
->info('Service name of platform')
->defaultValue(PlatformInterface::class)
->end()
->arrayNode('model')
->children()
->scalarNode('name')->isRequired()->end()
->scalarNode('version')->defaultNull()->end()
->arrayNode('options')
->scalarPrototype()->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
};
3 changes: 0 additions & 3 deletions src/ai-bundle/phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ parameters:
level: 6
paths:
- src/
excludePaths:
analyse:
- src/DependencyInjection/Configuration.php
Loading
Loading