Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Component, Multiple outputs and type refactor #2246

Merged
merged 747 commits into from
Jun 21, 2024
Merged

New Component, Multiple outputs and type refactor #2246

merged 747 commits into from
Jun 21, 2024

Conversation

ogabrielluiz
Copy link
Contributor

This PR adds a new way of building Langflow Components, adds the possibility of defining more than one output and adds the io module that exposes many types of inputs.

The components that inherit from CustomComponent should still work.

Components now mostly output Data(former Record) and Message.

MessageInput passes a Message object to the component while TextInput gets the .text from the Message and passes it as a string.

igorrCarvalho and others added 30 commits June 18, 2024 19:35
…nstead of a single ContractEdge instance

🐛 (types.py): Fix _get_result method to handle multiple edges with the same target_id
📝 (types.py): Add comments to clarify the purpose of setting the result in the vertex of origin
The code changes in `chat.py` update the `build_vertex_stream` function to set the cache using `chat_service.set_cache` before closing the stream. This ensures that the cache is updated with the latest data before the stream is closed. The commit message follows the established convention of using a prefix to indicate the type of change.
The code changes in `base.py` add a `user_agent` attribute to the `Settings` class and a corresponding class method `set_user_agent` to set the user agent for API calls. If the `user_agent` is not provided, it defaults to "langflow". The method also updates the `USER_AGENT` environment variable and logs the new value. This refactor improves the flexibility and maintainability of the code. The commit message follows the established convention of using a prefix to indicate the type of change.
…re not properly assigned

🐛 (base.py): Fix issue where outputs were not initialized causing potential errors
…d langflow.inputs.TextInput

The code changes in `Webhook.py` update the `WebhookComponent` class to inherit from `langflow.custom.Component` instead of `langflow.custom.CustomComponent`. It also replaces the `langflow.schema.dotdict` import with `langflow.template.Output` and updates the `build_data` method to use the `self.data` attribute instead of the `data` parameter. Additionally, it adds a new input `TextInput` for providing a JSON payload. This refactor improves the consistency and readability of the code. The commit message follows the established convention of using a prefix to indicate the type of change.
…dNode

The code changes in `frontend_node/base.py` add a new method `validate_name_overlap` to the `FrontendNode` class. This method checks if any of the output names overlap with any of the input names and raises a `ValueError` if there is a duplication. This refactor improves the consistency and correctness of the code. The commit message follows the established convention of using a prefix to indicate the type of change.
…sses

The code changes update the langflow custom components to use specific input classes, such as IntInput and TextInput, instead of the generic field types. This refactor improves the clarity and type safety of the code.
…on_entrypoint_args to reflect correct number of arguments in build method

📝 (test_custom_component.py): reorganize import statements for better readability and consistency
♻️ (test_custom_component.py): refactor build method in YourComponent class to simplify and improve code readability
…omponents.py

The code changes in test_helper_components.py update the class name from DocumentToDataComponent to DocumentsToDataComponent. This refactor improves the clarity and consistency of the code.
…y path

The code changes in test_data_components.py update the `docs_path` variable to fix the directory path for loading components. The previous path was incorrect, and this update ensures that the correct path is used. This refactor improves the accuracy and reliability of the code.
The code changes in inputs.py add a new attribute `load_from_db` to the `SecretStrInput` class. This attribute controls whether the input should be loaded from the database or not. By default, it is set to `True`. This refactor improves the flexibility and configurability of the code.
…enAI exceptions

The code changes in exceptions.py add a new function `get_message_from_openai_exception` to handle exceptions raised by the OpenAI library. This function retrieves the error message from the exception and returns it. This refactor improves the error handling and enhances the code's robustness.
The code changes in loading.py add a filter to ignore Pydantic deprecation warnings when building custom components or components. This refactor improves the code's maintainability and ensures compatibility with the latest Pydantic version.
This commit refactors the TextOutputView component to handle a specific case where the `value` prop is an object with a `text` property. It updates the component to check if the `value` is an object and if it contains the `text` property. If so, it assigns the value of `value.text` to `value`. This change improves the flexibility and usability of the component.
This commit improves the handling of the inputValue in the GenericModal component. It checks if the inputValue is a string before assigning it to coloredContent. Additionally, it updates the classNames in the JSX elements to ensure consistent ordering. These changes enhance the reliability and maintainability of the code.
This refactor adds a new method `validate` to the `FrontendNode` class in the `frontend_node/base.py` file. The `validate` method now calls two separate validation methods: `validate_name_overlap` and `validate_attributes`. The `validate_name_overlap` method checks for any overlap between input and output names, while the `validate_attributes` method checks for reserved attributes in the input and output names. These changes improve the reliability and maintainability of the code.
ogabrielluiz and others added 23 commits June 21, 2024 11:18
…y formatted and displayed in the HumanMessage object

📝 (message.py): improve the logic for handling message content and formatting to ensure correct display in the HumanMessage object
…of result.text in test_directory_without_mocks
Copy link

vercel bot commented Jun 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langflow ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2024 7:00pm

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Jun 21, 2024
@ogabrielluiz ogabrielluiz merged commit 65e1c42 into dev Jun 21, 2024
32 of 38 checks passed
@ogabrielluiz ogabrielluiz deleted the two_edges branch June 21, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants