Commit 8fbb310
committed
[AI Bundle][Platform] Add
This PR revolutionizes model configuration in the Symfony AI bundle by simplifying
the way models are configured and eliminating the need for explicit class definitions
in most use cases. The changes make model configuration more intuitive and maintainable
while providing full backwards compatibility.
- **Added platform-specific ModelCatalog classes** for OpenAI, Anthropic, Mistral, Perplexity, Gemini, and Cerebras
- **Automatic model class inference** based on platform and capabilities
- **Eliminates need for explicit class configuration** in most scenarios
- Each platform now provides its own model catalog with predefined capabilities
- **Direct model string support**: `model: 'gpt-4o-mini?temperature=0.5&max_tokens=1000'`
- **Query parameter parsing** embedded directly in model names
- **Traditional name/options structure** still supported for backwards compatibility
- **Validation prevents conflicting configurations** (query string + options object)
- **New `PlatformInterface::getModelCatalog()` method** for accessing platform model catalogs
- **Enhanced `AbstractModelCatalog`** with validation for empty model names
- **New `AutoDiscoveryModelCatalog`** for automatic capability detection
- **Updated platform factories** to create bridge-specific model catalogs
- **Updated AI Bundle configuration** (`config/options.php`) to support direct model strings
- **Enhanced bundle class** (`AiBundle.php`) to handle new model configuration patterns
- **Removed hardcoded model class assumptions** throughout the bundle
- **Updated 40+ test files** to use Model objects instead of raw strings
- **Enhanced InputProcessor tests** to validate new configuration patterns
- **Added comprehensive test coverage** for all new ModelCatalog implementations
- **Updated agent tests** to use proper Model instances
```yaml
ai:
model:
openai:
custom-gpt-4:
class: OpenAi\Gpt
capabilities:
- input_messages
- output_text
- tool_calling
```
```yaml
ai:
agent:
my_agent:
platform: openai
model: 'gpt-4o-mini?temperature=0.5&max_tokens=1000'
ai:
agent:
my_agent:
platform: openai
model:
name: gpt-4o-mini
options:
temperature: 0.5
max_tokens: 1000
ai:
model:
openai:
custom-gpt-4:
capabilities:
- !php/const Symfony\AI\Platform\Capability::INPUT_MESSAGES
- !php/const Symfony\AI\Platform\Capability::OUTPUT_TEXT
- !php/const Symfony\AI\Platform\Capability::TOOL_CALLING
agent:
my_agent:
platform: openai
model: 'custom-gpt-4?temperature=0.3'
```
1. **Dramatically Simplified Configuration**: No more need to specify model classes for standard platform models
2. **Enhanced Developer Experience**: Intuitive query parameter syntax for model options
3. **Type Safety**: Enum constants ensure valid capability values
4. **Automatic Model Discovery**: Platform-specific catalogs automatically infer appropriate model classes
5. **Validation**: Built-in prevention of conflicting configuration patterns
6. **Full Backwards Compatibility**: Existing configurations continue to work unchanged
- **ModelCatalog Interface**: Each platform now implements its own model catalog
- **Query String Parser**: Parses model options from URL-style query parameters
- **Capability Auto-Detection**: Automatically determines model capabilities based on platform standards
- **Configuration Validation**: Prevents invalid combinations of configuration approaches
- **Seamless Migration**: Existing model configurations work without modification
This change significantly reduces configuration complexity while maintaining the full power and flexibility of the Symfony AI platform integration.ModelCatalog
1 parent 6713439 commit 8fbb310
File tree
335 files changed
+5672
-1942
lines changed- demo/config/packages
- examples
- aimlapi
- albert
- anthropic
- azure
- bedrock
- cerebras
- dockermodelrunner
- document
- elevenlabs
- gemini
- huggingface
- indexer
- lmstudio
- memory
- misc
- mistral
- ollama
- openai
- openrouter
- perplexity
- rag
- replicate
- scaleway
- toolbox
- transformers
- vertexai
- voyage
- src
- agent
- src
- Memory
- tests
- InputProcessor
- Memory
- ai-bundle
- config
- src
- Profiler
- tests
- DependencyInjection
- Profiler
- platform
- src
- Bridge
- AiMlApi
- Albert
- Anthropic
- Azure
- Meta
- OpenAi
- Bedrock
- Nova
- Cerebras
- DockerModelRunner
- ElevenLabs
- Gemini
- HuggingFace
- LmStudio
- Meta
- Mistral
- Ollama
- OpenAi
- OpenRouter
- Perplexity
- Replicate
- Scaleway
- TransformersPhp
- VertexAi
- Embeddings
- Gemini
- Voyage
- ModelCatalog
- Tests
- tests
- Bridge
- AiMlApi
- Albert
- Anthropic
- Contract
- Azure
- Meta
- OpenAi
- Bedrock
- Nova
- Cerebras
- DockerModelRunner
- ElevenLabs
- Contract
- Gemini
- Contract
- Embeddings
- Mistral
- Contract
- Ollama
- Contract
- OpenAi
- Contract
- DallE
- Embeddings
- Gpt
- Whisper
- Perplexity
- Contract
- Scaleway
- Embeddings
- Llm
- TransformersPhp
- VertexAi
- Contract
- Embeddings
- Gemini
- Voyage
- Contract/Normalizer/Message
- store
- src/Document
- tests
- Document
- Double
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
335 files changed
+5672
-1942
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 7 | + | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 15 | + | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 23 | + | |
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
34 | | - | |
| 27 | + | |
35 | 28 | | |
36 | 29 | | |
37 | 30 | | |
| |||
40 | 33 | | |
41 | 34 | | |
42 | 35 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 36 | + | |
46 | 37 | | |
47 | 38 | | |
48 | 39 | | |
| |||
55 | 46 | | |
56 | 47 | | |
57 | 48 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 49 | + | |
61 | 50 | | |
62 | 51 | | |
63 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 20 | | |
27 | 21 | | |
28 | 22 | | |
| |||
31 | 25 | | |
32 | 26 | | |
33 | 27 | | |
34 | | - | |
| 28 | + | |
35 | 29 | | |
36 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 23 | | |
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
| 27 | + | |
34 | 28 | | |
35 | 29 | | |
36 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 18 | | |
23 | | - | |
| 19 | + | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
| |||
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | | - | |
| 42 | + | |
46 | 43 | | |
47 | 44 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
| 28 | + | |
31 | 29 | | |
32 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
| 28 | + | |
31 | 29 | | |
32 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
| 27 | + | |
30 | 28 | | |
31 | 29 | | |
0 commit comments