🔧 chore(utils.py): use ChatConfig to set streaming option

The first change removes an extra blank line in the ChatManager class. The second change updates the try_setting_streaming_options function to use the ChatConfig class to set the streaming option instead of hardcoding it. This makes the code more modular and easier to maintain.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-27 10:16:41 -03:00
commit b741853454
2 changed files with 6 additions and 2 deletions

View file

@ -209,3 +209,5 @@ class ChatManager:
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
self.disconnect(client_id) self.disconnect(client_id)

View file

@ -4,10 +4,12 @@ import os
from io import BytesIO from io import BytesIO
import re import re
import yaml import yaml
from langchain.base_language import BaseLanguageModel from langchain.base_language import BaseLanguageModel
from PIL.Image import Image from PIL.Image import Image
from langflow.utils.logger import logger from langflow.utils.logger import logger
from langflow.chat.config import ChatConfig
def load_file_into_dict(file_path: str) -> dict: def load_file_into_dict(file_path: str) -> dict:
@ -49,9 +51,9 @@ def try_setting_streaming_options(langchain_object, websocket):
if isinstance(llm, BaseLanguageModel): if isinstance(llm, BaseLanguageModel):
if hasattr(llm, "streaming") and isinstance(llm.streaming, bool): if hasattr(llm, "streaming") and isinstance(llm.streaming, bool):
llm.streaming = True llm.streaming = ChatConfig.streaming
elif hasattr(llm, "stream") and isinstance(llm.stream, bool): elif hasattr(llm, "stream") and isinstance(llm.stream, bool):
llm.stream = True llm.stream = ChatConfig.streaming
return langchain_object return langchain_object