This change adds error handling to catch a specific exception that may occur when processing documents with the ChromaDB library. If there are not enough documents for indexing, the error message will suggest reducing the chunk size in TextSplitter.
Add a new file `callback.py` that contains a new class `StreamingLLMCallbackHandler` that inherits from `AsyncCallbackHandler`. This class handles streaming LLM responses. It has a constructor that takes a `websocket` parameter and sets it as an instance variable. It also has an `on_llm_new_token` method that takes a `token` parameter and sends a `ChatResponse` object to the `websocket` instance variable.
Update `chat_manager.py` to import the new `StreamingLLMCallbackHandler` class. Add a new function `try_setting_streaming_options` that takes a `langchain_object` and a `websocket` parameter. This function checks if the `llm` attribute of the `langchain_object` is an instance of `OpenAI`, `ChatOpenAI`, `AzureOpenAI`, or `AzureChatOpenAI`. If it is, it sets the
"UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 9465: character maps to
<undefined>".
Specifying the encodint type in the function helps to fix that error.
fix(schemas.py): add validation for file response type and data type
test(test_websocket.py): remove data and data_type fields from ChatResponse messages in tests
feat(cache): add support for multiple clients and context manager to set client_id
feat(cache): add observer pattern to notify on cache changes
feat(cache): add async observer pattern to notify on cache changes in async functions
feat(cache): add methods to add pandas DataFrame or Series and PIL Image to cache
feat(cache): add method to get an object from cache by key
feat(cache): add method to get the last added item in cache