Skip to content

[Platform] Support streaming output for Ollama #338

@logicalor

Description

@logicalor

Currently, if you set stream to true when setting Ollama options it will throw an error.

example:

$result = $agent->call(
    $messages, [
        'stream' => true,
    ]
);

results in:

PHP Fatal error:  Uncaught Symfony\Component\HttpClient\Exception\JsonException: Syntax error for "http://localhost:11434/api/chat". in /.../vendor/symfony/http-client/Response/CommonResponseTrait.php:90
Stack trace:
#0 /.../vendor/symfony/ai-platform/src/Result/RawHttpResult.php(28): Symfony\Component\HttpClient\Response\AsyncResponse->toArray()
#1 /.../vendor/symfony/ai-platform/src/Bridge/Ollama/OllamaResultConverter.php(47): Symfony\AI\Platform\Result\RawHttpResult->getData()
#2 /.../vendor/symfony/ai-platform/src/Result/ResultPromise.php(48): Symfony\AI\Platform\Bridge\Ollama\OllamaResultConverter->convert()
#3 /.../vendor/symfony/ai-platform/src/Result/ResultPromise.php(37): Symfony\AI\Platform\Result\ResultPromise->await()
#4 /.../vendor/symfony/ai-agent/src/Agent.php(82): Symfony\AI\Platform\Result\ResultPromise->getResult()
#5 /.../src/app.php(26): Symfony\AI\Agent\Agent->call()
#6 {main}
  thrown in /.../vendor/symfony/http-client/Response/CommonResponseTrait.php on line 90

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions