299 ollama client does not work with stream#309
Open
BalasubramanyamEvani wants to merge 2 commits into
Open
Conversation
… created a mock class::TestGeneratorWithStream for simulating streamed API response
liyin2015
requested changes
Dec 18, 2024
| s = f"model_kwargs={self.model_kwargs}, model_type={self.model_type}" | ||
| return s | ||
|
|
||
| def _process_chunk(self, chunk: Any) -> GeneratorOutput: |
Member
There was a problem hiding this comment.
it specifies only one output, but you returned a tuple.
Ensure we add code linting @fm1320 by developers to check these basics
Author
There was a problem hiding this comment.
Thanks for. the review. Yes, that's my fault. I will fix this.
| log.error(f"Error in stream processing: {e}") | ||
| yield GeneratorOutput(error=str(e)) | ||
|
|
||
| return GeneratorOutput(data=process_stream(), raw_response=output) |
Member
There was a problem hiding this comment.
dont separate the code, it changed too much, and its better to minimize the change, so just add the initial code back to the else
Author
There was a problem hiding this comment.
Understood. I’ll proceed with this approach then. It seems there’s no longer a need for the additional _process_chunk function I had added earlier then?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR addresses the issue where the application fails to work when the
streamparameter is set toTruein theadalflow.components.model_client.ollama_client::OllamaClientclass. The issue is traced to theadalflow.core.generator.py_post_callmethod, which does not currently handle streaming correctly.Fixes #299
_post_callmethod.output_processors.Usage Updates
The updated usage for the
streamparameter is as follows:Tests Added
TestGeneratorWithStream, is added intest_generator.pyto verify the streaming behavior.GeneratorTyperesponse from theparse_chat_completionmethod and validates the output for streamed data.Tests output (local) after changes:
Breaking Changes
As far as I can test, this PR does not introduce any breaking changes. Existing functionality for non-streaming cases remains unaffected.
Before submitting