🐛 fix(utils.py): add type check for streaming and stream attributes before setting them to True

The code now checks if the streaming and stream attributes are boolean before setting them to True. This ensures that the attributes are not set to True if they are not boolean, which could cause errors in the code.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-08 00:40:51 -03:00
commit 8e2bacad9a

View file

@ -46,9 +46,9 @@ def try_setting_streaming_options(langchain_object, websocket):
llm = langchain_object.llm_chain.llm
if isinstance(llm, BaseLanguageModel):
if hasattr(llm, "streaming"):
if hasattr(llm, "streaming") and isinstance(llm.streaming, bool):
llm.streaming = True
if hasattr(llm, "stream"):
elif hasattr(llm, "stream") and isinstance(llm.stream, bool):
llm.stream = True
return langchain_object