Skip to content

[Platform] Boolean options not supported in AbstractModelCatalog::parseModelName() #713

@sonnymilton

Description

@sonnymilton

Currently, AbstractModelCatalog::parseModelName() relies on AbstractModelCatalog::convertNumericStrings() which only converts numeric strings to integers/floats.

However, boolean-like query parameters (e.g. ?think=false) are always parsed as strings. This makes it harder to pass boolean options to models, since they need to be manually casted.

Example:

$catalog = new \Symfony\AI\Platform\Bridge\Ollama\ModelCatalog();
$model = $catalog->getModel('qwen3:0.6b?think=false');
$client = new \Symfony\AI\Platform\Bridge\Ollama\OllamaClient(
    Symfony\Component\HttpClient\HttpClient::create(),
    $_ENV['OLLAMA_HOST']
);
$options = $model->getOptions(); // ['think' => 'false']

// will throw an exception because ollama responds with 400 Bad request
// {"error":"invalid think value: \"false\" (must be \"high\", \"medium\", \"low\", true, or false)"}
$client->request(
    $model,
    [new \Symfony\AI\Platform\Message\UserMessage(
        new \Symfony\AI\Platform\Message\Content\Text('Hello world'),
    )],
    $model->getOptions()
);

Here think=false is passed as a string ('false'), but Ollama server expects a real boolean false.

Expected behavior:

Boolean-like strings should be automatically converted to booleans.

Proposed solution:

Introduce a more general converter, e.g. convertScalarStrings(), that handles both numeric and boolean strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingPlatformIssues & PRs about the AI Platform componentStatus: Needs Review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions