-
Notifications
You must be signed in to change notification settings - Fork 19k
!fix(core): _should_stream
respects streaming
param
#32707
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
CodSpeed WallTime Performance ReportMerging #32707 will improve performances by 13.02%Comparing
|
Benchmark | BASE |
HEAD |
Change | |
---|---|---|---|---|
⚡ | test_import_time[BaseChatModel] |
586.7 ms | 519.1 ms | +13.02% |
⚡ | test_import_time[ChatPromptTemplate] |
663.3 ms | 602.7 ms | +10.06% |
⚡ | test_import_time[Document] |
229.3 ms | 206.9 ms | +10.86% |
⚡ | test_import_time[InMemoryRateLimiter] |
182 ms | 164.6 ms | +10.54% |
⚡ | test_import_time[PydanticOutputParser] |
597.8 ms | 542.4 ms | +10.2% |
CodSpeed Instrumentation Performance ReportMerging #32707 will not alter performanceComparing Summary
|
@@ -350,7 +350,7 @@ def mock_glm4_completion() -> list: | |||
|
|||
async def test_glm4_astream(mock_glm4_completion: list) -> None: | |||
llm_name = "glm-4" | |||
llm = ChatOpenAI(model=llm_name, stream_usage=True) | |||
llm = ChatOpenAI(model=llm_name, stream_usage=True, streaming=True) |
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.
why add these?
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.
The unit tests needed updating because they were relying on the old behavior where the streaming parameter was ignored. Now they need to set streaming=True
to test streaming. This is breaking - I'll update description to reflect.
_should_stream
respects streaming
param_should_stream
respects streaming
param
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.
What is motivating this change?
I think the underlying issue is that streaming: bool = False
on BaseChatOpenAI has no sentinel value— ideally it should be streaming: bool | None = None
.
I think intended usage is that
llm = ChatOpenAI(model="...")
llm.stream(...)
streams without you having to explicitly specify streaming=True
in the constructor. Otherwise this is (very) breaking and it's unclear what the benefit is.
Can re-open if needed. |
Important
This is a breaking change
_should_stream()
inBaseChatModel
wasn't checking the instance-level streaming parameter, leading to streaming being enabled even when explicitly disabledChatOpenAI().stream()
always attempted streaming (ignoredstreaming=False
)ChatOpenAI().stream()
respectsstreaming=False
and falls back toinvoke()
Any existing code doing: