Skip to content

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

Open
chr-hertel wants to merge 1 commit into
symfony:mainfrom
chr-hertel:feat/model-class
Open

[Platform] Accept Model instance in Platform::invoke()#2139
chr-hertel wants to merge 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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