-
-
Notifications
You must be signed in to change notification settings - Fork 57
[Platform][Ollama] Support streaming output #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Can you please add an example in examples/ directory? Thanks |
@OskarStark updated with an example |
Thanks It looks like your committer email is not associated with your GitHub account |
@OskarStark thanks, hadn't noticed that. Added. |
if ($msg) { | ||
yield $msg; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for @chr-hertel (not relevant for the review), isn't the same situation that we're facing in #324?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not since this is only working on the response in the ResultConverter, which is only called when finally fetching the content. In #324 the stream
is called already in the client
// Emit each chunk as it is received | ||
foreach ($result as $chunk) { | ||
echo $chunk->getContent(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
echo \PHP_EOL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call the file only stream.php
- it is more consistent with the other stream examples, and ollama
is basically the folder already
$data = json_decode($json, true); | ||
if (!\is_array($data)) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this to the result converter - it's their job to convert to data. fine with having the value object, but let's keep it simple than 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @logicalor for reporting and working on this - we need this :)
Made some comments, but i think all in all we're close to merging it 👍
Both a bug fix and a feature? Support streaming output from Ollama, preventing an error being thrown if streaming output is sent with the chat request.