Small bugfixes and improvements (#514)
# Pull Request Description ## Summary This Pull Request includes several code improvements, refactoring, feature additions, and documentation updates mainly focused on enhancing the functionality and maintainability of the codebase. ## Details ### Refactoring and Improvements: - **Commit (5ea20aa) by @ogabrielluiz**: Unnecessary indentation in the `getPythonCode` function within `constants.tsx` has been removed to improve code readability. - **Commit (6886828) by @ogabrielluiz**: - Changed the `load_flow_from_json` function signature in `process.py` to accept either a JSON file path or a JSON object. - Updated the import statement for `Chain` in `base.py` to be more explicit by importing it from `langchain.chains.base` instead of `langflow.graph.vertex.types`. - Removed a print statement from the `process_tweaks` function in `process.py`. - Added an optional `tweaks` parameter to the `load_flow_from_json` function. - Changed the return type of the `build` method in the `Graph` class from `List[Vertex]` to `Chain`. - **Commit (83c28dc) by @ogabrielluiz**: The `process_tweaks` function in `process.py` has been refactored to improve readability and maintainability. An `apply_tweaks` function was added to apply tweaks to the node, and a `validate_input` function was added for input validation. The function now raises a `ValueError` if the input is not in the expected format. - **Commit (11185af) by @ogabrielluiz**: Refactored the `fix_memory_inputs` function in `process.py` to improve readability by reducing nesting. The function now checks if the `langchain_object` has a `memory` attribute and if it is not `None` before proceeding. The try-except block was also refactored to reduce nesting. - **Commit (f180fa6) by @ogabrielluiz**: The input parameter in `process.py` has been changed to accept a `Path` object in addition to a string or dictionary, improving the flexibility of the function and allowing for easier file handling. ### Features: - **Commit (8a5525f) by @ogabrielluiz**: The `getPythonCode` function in `constants.tsx` now accepts a `tweaks` parameter which is used to customize the behavior of the flow. A `buildTweaks` function generates the `tweaks` object which is passed to the `load_flow_from_json` function. - **Commit (c5d6f48) by @ogabrielluiz**: Added a `build_and_install` target to the `Makefile` to build the package and install it without running it. This is useful for building and installing on a remote server. Additionally, fixed the path to the `langflow.main` module in the backend target of the `Makefile`. ### Documentation: - **Commit (76a1265) by @ogabrielluiz**: Updated the Langflow API usage example in `README.md` to reflect the new API endpoint URL. Added a new optional `tweaks` parameter to the `run_flow` function for flow customization and updated the example code accordingly. ### Other: - **Commit (0dcd93e) by @lucaseduoli**: Added Discord and Twitter icons, and GitHub stars. - **Commit (0dcd93e) by @lucaseduoli**: Fixed the Twitter link.
G
Gustavo Schaedler committed
fa2d2fbc973e907e9b53651b6c7838413a4ae6d7
Committed by GitHub <noreply@github.com>
on 6/19/2023, 8:10:41 PM