Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Platform] Accept Model instance in Platform::invoke() - #2139

Merged
chr-hertel merged 1 commit into
symfony:mainfrom
chr-hertel:feat/model-class
Jun 11, 2026
Merged

[Platform] Accept Model instance in Platform::invoke()#2139
chr-hertel merged 1 commit into
symfony:mainfrom
chr-hertel:feat/model-class

Conversation

@chr-hertel

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? yes
Docs? yes
Issues -
License MIT

Platform bridges ship static model catalogs that go stale as providers release new models. Today, using a model that's not in the shipped catalog means registering additionalModels, swapping in a FallbackModelCatalog, or patching the lib.

This widens Platform::invoke() (and Provider::invoke() / Provider::supports()) to accept string|Model, so a fully defined model can be handed over per call, bypassing the catalog entirely:

use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
use Symfony\AI\Platform\Capability;

$model = new Gpt('gpt-newest', [
    Capability::INPUT_MESSAGES,
    Capability::OUTPUT_TEXT,
    Capability::TOOL_CALLING,
], ['temperature' => 0.5]);

$result = $platform->invoke($model, $messages);

A string keeps the existing catalog-based routing untouched. A Model instance is routed to the first provider whose model clients accept it.

Note: you must pass a bridge-specific subclass (Gpt, Claude, …), not the base Model, since model clients, result converters and normalizers dispatch on the concrete class. All bridge model classes are directly instantiable (the final ones included — final only blocks subclassing, not new).

@chr-hertel
chr-hertel merged commit 43c2212 into symfony:main Jun 11, 2026
424 checks passed
@chr-hertel
chr-hertel deleted the feat/model-class branch June 11, 2026 21:26
@chr-hertel chr-hertel added the BC Break Breaking the Backwards Compatibility Promise label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BC Break Breaking the Backwards Compatibility Promise Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants