|
| 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 | +}; |
0 commit comments