fix: Refactor file reading and async task creation, fix return type in vertex_builds model #4273
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.
This pull request includes several changes aimed at improving asynchronous task handling, fixing encoding issues, and modifying serialization methods. The most important changes are grouped by their themes below:
Asynchronous Task Handling Improvements:
src/backend/base/langflow/api/v1/chat.py
: Simplified the creation of asynchronous tasks by directly calling async functions instead of usingasyncio.to_thread
. [1] [2]Encoding Fixes:
src/backend/base/langflow/custom/directory_reader/directory_reader.py
: Fixed an issue with reading files on Windows by handlingUnicodeDecodeError
and opening the file in binary mode if needed.Serialization Method Changes:
src/backend/base/langflow/services/database/models/vertex_builds/model.py
: Changed the return type of theserialize_params
method fromdict
tostr
to ensure proper serialization.Refactored the file reading logic to avoid unclosed resources and improved the async task creation by removing unnecessary thread usage. Additionally, fixed the return type of 'serialize_params' to string in the vertex_builds model. These changes enhance the efficiency and reliability of the code.