Commit graph

268 commits

Author SHA1 Message Date
Edwin Jose
b2ef231cd4
fix: Ollama Model Component build config updates and formats info to prevent issues in DSLF. (#5978)
* Update ollama.py

* update ib build config

* [autofix.ci] apply automated fixes

* improves stability of build config.

* [autofix.ci] apply automated fixes

* Update ollama.py

* test: update ChatOllamaComponent test to validate Ollama URL handling

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-28 22:38:08 +00:00
github-actions[bot]
2d3bfbc6fb
chore: update test durations (#5968)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-28 13:14:32 +00:00
Gabriel Luiz Freitas Almeida
0ef54c5ad9
fix: Ensure importability of modules not included in __init__.py files (#5965)
* fix: ensure that modules not included in __init__.py files are importable

* test: add test for module import in custom component
2025-01-28 12:18:40 +00:00
github-actions[bot]
e8879ff79f
chore: update test durations (#5951)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-27 14:24:33 +00:00
github-actions[bot]
7b6c0be380
chore: update test durations (#5909)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
2025-01-24 13:43:15 +00:00
anovazzi1
1df53a87f4
Fix: update initial graph sort for disconnected graph (#5867)
* refactor: add test for sorting vertices in unconnected graph

Add a new test case to the `test_get_sorted_vertices_with_unconnected_graph` function in the `test_utils.py` file. This test verifies the correct sorting of vertices in an unconnected graph. The test defines a graph structure and checks that the first layer contains the input vertices and the remaining layers contain the rest of the vertices in the correct order.

Refactor the code to improve test coverage and ensure the correctness of the sorting algorithm.

* refactor: improve handling of unconnected vertices in graph sorting

* [autofix.ci] apply automated fixes

* Refactor: Update start_component_id in test_get_sorted_vertices_with_unconnected_graph

The start_component_id parameter in the test_get_sorted_vertices_with_unconnected_graph function was updated to "A" to improve the handling of unconnected vertices in graph sorting.

* Refactor: Improve handling of unconnected vertices in graph sorting

* [autofix.ci] apply automated fixes

* Refactor: Add test_filter_vertices_from_vertex function to test_utils.py

* Refactor: Add error handling for missing graph information in filter_vertices_up_to_vertex and filter_vertices_from_vertex functions

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-22 20:27:23 +00:00
Edwin Jose
229ba19a66
feat: add WikiData Component and depeciates the WikiData API tool component (#5872)
* update

* [autofix.ci] apply automated fixes

* Update test_wikidata_api.py

* [autofix.ci] apply automated fixes

* Update wikidata.py

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-22 18:30:01 +00:00
Edwin Jose
dcd68c5f4e
feat: adds Wikipedia Component and deprecates the wikipedia API tool component (#5871)
* update

* Update test_wikipedia_api.py

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/components/tools/wikipedia.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update test_wikipedia_api.py

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-22 18:29:53 +00:00
github-actions[bot]
c9d5b6f9f3
chore: update test durations (#5857)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-22 15:19:57 +00:00
github-actions[bot]
0488ff2483
chore: update test durations (#5827)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-22 01:13:00 +00:00
Raphael Valdetaro
bd8dbdfab6
feat: add arxiv component (#5634)
* feat: add arxiv component

* [autofix.ci] apply automated fixes

* test: add initial test suite for arxiv component

* fix: correct test formatting for ArXiv component

* fix: implement tests for ArXivComponent following TestBatchRunComponent pattern

* fix: ArXivComponent test formatting

* [autofix.ci] apply automated fixes

* refactor: update imports and skip version tests for new component

* fix: fix line breaks in test file

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-21 20:20:26 +00:00
Deon Sanchez
a06cca4a8c
feat: add dialog support to dropdown components and enhance AstraDB (#5349)
* feat: add dialog support to dropdown components and enhance AstraDB integration

- Introduced a new NodeDialog component for improved user interaction when connecting to Astra DB.
- Updated AstraDBVectorStoreComponent to include a dialog option for creating new collections.
- Enhanced dropdown components to support dialog functionality, allowing users to create new options directly from the dropdown.
- Added `hasDialog` property to relevant component types to manage dialog visibility.
- Refactored utility functions to support new naming conventions and improve code clarity.

* [autofix.ci] apply automated fixes

* Remove creation parameters, add new inputs for dialog

* Update astradb.py

* [autofix.ci] apply automated fixes

* Update the mixins for dialog_inputs

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* refactor: standardize JSON formatting and clean up input types in Vector Store RAG configuration

- Reformatted JSON structure for better readability, ensuring consistent indentation and line breaks.
- Updated input types across various components to use array notation for clarity.
- Removed extraneous entries in package-lock.json to streamline dependencies.
- Enhanced overall maintainability of the configuration files.

* Add new options_metadata field to dropdown mixin

* Update test_astra_component.py

* Properly set dictionary mapping

* Update astradb.py

* Fix collection loading

* [autofix.ci] apply automated fixes

* Update astradb.py

* Update astradb.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Enhance AstraDB integration and update dropdown components

- Updated the AstraDBVectorStoreComponent to include new input fields for database and collection creation, with default options for selection.
- Refactored dropdown components to support dynamic dialog inputs, improving user interaction for creating new options and refreshing lists.
- Updated package-lock.json to reflect dependency upgrades, including Rollup and SWC packages.

This commit improves the functionality and usability of the AstraDB integration and dropdown components, ensuring a smoother user experience.

* Update astradb.py

* Fix autodetection

* Enhance dropdown components to support options metadata

- Added `optionsMetaData` prop to Dropdown and DropdownComponent for improved data handling.
- Updated rendering logic in Dropdown to display metadata alongside options, enhancing user experience.
- Modified type definitions to include `optionsMetaData` in relevant components.

These changes improve the flexibility and usability of dropdown components, allowing for richer data presentation.

* Refactor and enhance AstraDB integration and dropdown components

- Updated the `Vector Store RAG.json` configuration for improved formatting and consistency in output and input types.
- Enhanced the `NodeDialogComponent` to accept `dialogInputs` as a prop, allowing for more dynamic content rendering.
- Modified the `Dropdown` component to use `onSelect` instead of `onClick` for better accessibility and user interaction.
- Improved rendering logic in the `Dropdown` component to conditionally display icon options based on the presence of `dialogInputs`.

These changes enhance the usability and flexibility of the AstraDB integration and dropdown components, providing a more intuitive user experience.

* Don't inherit from dict input in new inputs

* [autofix.ci] apply automated fixes

* Update astradb.py

* update logic for dropdown

* Fix the number of records per collection

* Update astradb.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* feat: Enhance Dropdown and Parameter Render Components

- Updated Dropdown component to integrate post template value handling and refresh functionality.
- Refactored ParameterRenderComponent to conditionally render based on dialog inputs.
- Improved DropdownComponent to accept additional props for better flexibility.

These changes improve the overall functionality and usability of the dropdown components within the application.

* Set unknown to none to hide unavailable fields

* Update astradb.py

* Refactor Dropdown Component for Enhanced Usability

- Removed unnecessary state initialization and improved code readability.
- Updated button elements within the dropdown to enhance user interaction.
- Added loading state indication for the refresh button.
- Filtered out null values from options metadata for cleaner rendering.

These changes streamline the dropdown functionality and improve the user experience.

* Refactor NodeDialog, Dropdown, and ParameterRender Components

- Commented out debug logs in NodeDialogComponent to clean up console output.
- Enhanced Dropdown component to conditionally render icon options based on dialog inputs.
- Updated ParameterRenderComponent to check for the length of dialog inputs before rendering.

These changes improve code readability and ensure components behave correctly based on input conditions.

* [autofix.ci] apply automated fixes

* Cleanup some tests

* Fix ruff style issue

* [autofix.ci] apply automated fixes

* Fix environment specification

* [autofix.ci] apply automated fixes

* Update starter project template

* Update astradb.py

* Remove backwards compatibility features

* [autofix.ci] apply automated fixes

* Small tweak to autodetect

* [autofix.ci] apply automated fixes

* Refactor NodeDialogComponent to Dynamically Render Inputs

- Replaced static content in NodeDialogComponent with dynamic rendering based on dialogInputs.
- Introduced NodeInputField and RenderInputParameters components for better modularity.
- Enhanced footer with Cancel and Save buttons, improving user interaction.

These changes enhance the flexibility and usability of the NodeDialogComponent, allowing it to adapt to varying input configurations.

* Refactor NodeDialogComponent: Remove Unused Imports

- Commented out unused imports in NodeDialogComponent to clean up the code.
- This change enhances code readability and prepares the component for future updates.

No functional changes were made; the focus was on improving code quality.

* Refactor Dropdown and ParameterRender Components for Improved Readability and Functionality

- Renamed functions in Dropdown component for clarity: `renderOptionsList` and `renderCreateOptionDialog` to `oldRenderOptionsList` and `renderCustomOptionDialog`, respectively.
- Enhanced the rendering logic in Dropdown to streamline the display of options and metadata.
- Simplified the return structure in ParameterRenderComponent to always render the RefreshParameterComponent, improving code consistency.
- Updated RefreshParameterComponent to conditionally display the refresh button based on the presence of dialog inputs.

These changes improve code readability and maintainability while ensuring consistent behavior across components.

* [autofix.ci] apply automated fixes

* Add the new naming conventions to deletion fields

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Add new cloud provider options for database creation

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Make dialog inputs a dictionary of inputs

* [autofix.ci] apply automated fixes

* Update astradb.py

* Update astradb.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Update astradb.py

* [autofix.ci] apply automated fixes

* added mock data for testing

* Clean up the reactive flow

* [autofix.ci] apply automated fixes

* Fix the dialog inputs

* Update Vector Store RAG.json

* Update Vector Store RAG.json

* Update astradb.py

* Update astradb.py

* [autofix.ci] apply automated fixes

* Update astradb.py

* Update astradb.py

* Switch dialog inputs from list to dictionary

* Update astradb.py

* Refactor NodeDialogComponent to utilize useDialogSubmit hook for handling dialog submissions and streamline input rendering. Remove unused props and mock data, enhancing clarity and maintainability. Update DropdownComponent to remove unnecessary content prop. Introduce useDialogSubmit hook for improved API interaction and loading state management.

* New structure for dialog inputs

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* No need for the input type on token

* Flip order of ingest and search

* [autofix.ci] apply automated fixes

* Remove id field from factory

* Remove other id field

* [autofix.ci] apply automated fixes

* Refactor directory_reader.py to simplify file filtering logic

* Refactor flowSidebarComponent to filter out bundles and custom components in CategoryGroup

* [autofix.ci] apply automated fixes

* Refactor NodeDialogComponent to utilize dialogInputs directly, removing mock data and enhancing parameter rendering. Update Dropdown and ParameterRenderComponent types to accept single dialogInputs object. Remove unused useDialogSubmit hook.

*  (NodeDialogComponent/index.tsx): Introduce handleNewValue function to handle updating node template values based on user input
🔧 (NodeDialogComponent/index.tsx): Add support for process.env.PORT environment variable to be able to run app on a configurable port
🔧 (dropdownComponent/index.tsx): Add nodeId prop to Dropdown component to pass node id for better context
🔧 (parameterRenderComponent/index.tsx): Update handleOnNewValue prop to accept key parameter for better handling of new values
🔧 (parameterRenderComponent/types.ts): Add nodeId property to BaseInputProps type for better context and consistency

* Don't load the new collection names from db

* Update astradb.py

* Temporary disabling of dialog inputs functionality

* Update directory_reader.py

* Fix problematic uv.lock line

* Update uv.lock

* Update Vector Store RAG.json

* Update Vector Store RAG.json

* refactor: enhance dropdown and refresh button logic for better user experience

- Updated the dropdown component to disable the trigger button when there are no options available or when certain conditions are met.
- Removed the old render options list to streamline the dropdown rendering process.
- Improved the loading state handling in the dropdown to provide clearer feedback to users.
- Refactored the refresh button logic to ensure it only displays when appropriate conditions are met, enhancing the component's responsiveness.

* [autofix.ci] apply automated fixes

* Allow combobox specification of api endpoint

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Update Vector Store RAG.json

* Add back api_endpoint option for compatibility

* Update Vector Store RAG.json

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
2025-01-21 19:43:54 +00:00
Lucas Oliveira
f08c18f54a
feat: loop components handle ui and logic (#5744)
* Added backend to allow loop on output

* Added custom edge for looping components

* Added allows_loop to output type

* Added output_types to target handle if its a loop

* Fixed valid_connection to allow loops

* Added the loop handle to the outputs

* Added infinity icon

* Fixed clean edges to not delete loop edge

* Implement loop checking before build.

* Implemented looping indicator

* Fixed belzier path

* [autofix.ci] apply automated fixes

* 🔧 (reactflowUtils.ts): refactor cleanEdges and detectBrokenEdges functions to improve code readability and maintainability by extracting repeated logic into variables and reducing code duplication.

* [autofix.ci] apply automated fixes

* Add from_loop_target_handle method to TargetHandle class and update type field

* Enhance Edge class to handle loop target handles and validate loop edges

* Add output_names attribute and get_value_from_output_names method to Vertex class

* Add overlap check for input and output names in Component class

* Fix default value assignment in ComponentVertex to handle output names correctly

* Clarify error message for missing attributes in Component class

* Added backend to allow loop on output

* Added custom edge for looping components

* Added allows_loop to output type

* Added output_types to target handle if its a loop

* Fixed valid_connection to allow loops

* Added the loop handle to the outputs

* Added infinity icon

* Fixed clean edges to not delete loop edge

* Implement loop checking before build.

* Implemented looping indicator

* Fixed belzier path

* [autofix.ci] apply automated fixes

* 🔧 (reactflowUtils.ts): refactor cleanEdges and detectBrokenEdges functions to improve code readability and maintainability by extracting repeated logic into variables and reducing code duplication.

* [autofix.ci] apply automated fixes

* Add from_loop_target_handle method to TargetHandle class and update type field

* Enhance Edge class to handle loop target handles and validate loop edges

* Add output_names attribute and get_value_from_output_names method to Vertex class

* Add overlap check for input and output names in Component class

* Fix default value assignment in ComponentVertex to handle output names correctly

* Clarify error message for missing attributes in Component class

* feat: add loop component 🎁🎄 (#5429)

* add loop component 🎁🎄

* [autofix.ci] apply automated fixes

* fix: add loop component to init

* [autofix.ci] apply automated fixes

* refactor(loop): rename loop input variable and improve code quality

- Renamed 'loop' input to 'loop_input' for clarity.
- Simplified logic for checking loop input and aggregating results.
- Enhanced type hints for better code readability and maintainability.

* refactor(loop): add type hint to initialize_data method for improved clarity

* fix: mypy error incompatible return value type

* feat: adds test cases for loop component compatibility with the APIs, Loop component updates to support API (#5615)

* add loop component 🎁🎄

* [autofix.ci] apply automated fixes

* fix: add loop component to init

* [autofix.ci] apply automated fixes

* refactor(loop): rename loop input variable and improve code quality

- Renamed 'loop' input to 'loop_input' for clarity.
- Simplified logic for checking loop input and aggregating results.
- Enhanced type hints for better code readability and maintainability.

* refactor(loop): add type hint to initialize_data method for improved clarity

* adding test

* test cases added

* Update test_loop.py

* adding test

* test cases added

* Update test_loop.py

* update with the new test case method!

* Update test_loop.py

* tests  updates

* Update loop.py

* update fix

* issues loop issues

* reverting debug mode params

* solves lint errors and fix the tests

* fix: mypy error incompatible return value type

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Rodrigo Nader <rodrigosilvanader@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>

* feat: improve model input fields for Cohere component (#5712)

feat: improve model input fields for cohere component

1. Make api_key field required
2. Convert temperature to SliderInput with range 0-2
3. Add info description to temperature slider

* refactor: improve naming consistency in DataCombiner component (#5471)

* refactor: improve naming consistency in DataCombiner component

- Rename MergeOperation to DataOperation
- Rename component to DataCombinerComponent
- Convert operation enum values to uppercase
- Update method names for consistency

* [autofix.ci] apply automated fixes

* fix: resolved linting errors in __init__.py

* [autofix.ci] apply automated fixes

* Changed operation names to capitalize only first letter

* refactor: rename DataCombinerComponent to MergeDataComponent for better clarity and backwards compatibility

* [autofix.ci] apply automated fixes

* fix: Translate Portuguese text to English in merge_data.py

* feat: add required to data_inputs in MergeDataComponent

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>

* refactor: Refactor Wikipedia API component (#5432)

* refactor(wikipedia): Refactor Wikipedia API component

* test: add unit tests for WikipediaAPIComponent

* [autofix.ci] apply automated fixes

* refactor: improve WikipediaAPIComponent tests and fix lint issues

* [autofix.ci] apply automated fixes

* fix: resolve lint issues in WikipediaAPIComponent tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>

* fix: pass slider input values correctly, add test (#5735)

*  (base.py): Update field validation to include "slider" type in addition to "float" type for better parameter handling
📝 (constants.py): Add "slider" type to the list of DIRECT_TYPES for consistency and completeness

*  (test_inputs.py): add unit test for SliderInput class to ensure it initializes with correct value

* 🐛 (base.py): fix comparison of field type with a list by changing it to a set to ensure correct condition evaluation

* [autofix.ci] apply automated fixes

* fix format

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* feat: make AWS credentials required in bedrock component (#5710)

1. Make aws_access_key_id field required
2. Make aws_secret_access_key field required

* chore: update test durations (#5736)

Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>

* feat: add truncation to ResultDataResponse (#5704)

* chore: Update dependencies and improve platform markers in configuration files

- Added 'hypothesis' version 6.123.17 to dev-dependencies in pyproject.toml.
- Updated platform markers from 'sys_platform' to 'platform_system' for better compatibility in uv.lock, affecting multiple packages including 'jinxed', 'colorama', and 'appnope'.
- Ensured consistency in platform checks across various dependencies to enhance cross-platform support.

This update improves the project's dependency management and ensures better compatibility across different operating systems.

* feat: Enhance ResultDataResponse serialization with truncation support

- Introduced a new method `_serialize_and_truncate` to handle serialization and truncation of various data types, including strings, bytes, datetime, Decimal, UUID, and BaseModel instances.
- Updated the `serialize_results` method to utilize the new truncation logic for both individual results and dictionary outputs.
- Enhanced the `serialize_model` method to ensure all relevant fields are serialized and truncated according to the defined maximum text length.

This update improves the handling of large data outputs, ensuring that responses remain concise and manageable.

* fix: Reduce MAX_TEXT_LENGTH in constants.py from 99999 to 20000

This change lowers the maximum text length limit to improve data handling and ensure more manageable output sizes across the application.

* test: Add comprehensive unit tests for ResultDataResponse and VertexBuildResponse

- Introduced a new test suite in `test_api_schemas.py` to validate the serialization and truncation behavior of `ResultDataResponse` and `VertexBuildResponse`.
- Implemented tests for handling long strings, special data types, nested structures, and combined fields, ensuring proper serialization and truncation.
- Enhanced coverage for logging and output handling, verifying that all fields are correctly processed and truncated as per the defined maximum text length.
- Utilized Hypothesis for property-based testing to ensure robustness and reliability of the serialization logic.

This update significantly improves the test coverage for the API response schemas, ensuring better data handling and output management.

* feat: Add function to validate models with tool calling function and related fixes in agent component (#5720)

* Update nvidia.py

* update agent experience with improving model selection

update agent experience with improving model selection  and making only the tool calling models available.

* variable clean up

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/base/models/model_input_constants.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/base/models/model_input_constants.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* added default models

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* format errors solved

* [autofix.ci] apply automated fixes

* Update model.py

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* feat: assistants agent improvements (#5581)

* assistants agent improvements

* remove alembic init file

* vector store / file upload support

* use sync file object (required by sdk)

* steps

* self.tools initialization

* improvements for edwin

* add name and switch to MultilineInput

* ci fixes

* refactor: enhance flow type safety and clean up unused code (#5669)

* 📝 (use-save-flow.ts): add AllNodeType and EdgeType imports to improve type safety in useSaveFlow hook
📝 (index.tsx): remove unused setNoticeData function to clean up code and improve readability

* refactor: Remove unused code in GeneralPage component

* refactor: Remove unused code in cardComponent/index.tsx

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>

* feat: Add `required=True` to essential inputs across Langflow components (#5739)

* fix: add required validation to input fields

Ensures mandatory fields are properly marked as required across components.

* fix: add required validation to input fields

Ensures mandatory fields are properly marked as required across components.

* fix: add required validation to input fields

field: model_name

* fix: add required validation to input fields

field: model and base_url

* fix: add required validation to input fields
input: mistral_api_key

* fix: add required validation to input fields

inputs: model, base_url, nvidia_api_key

* fix: add required validation to input fields
inputs: model, base_url

* fix: add required validation to input fields

input: openai_api_key

* fix: add required validation to input fields
inputs: message, embedding_model

* fix: add required validation to input fields
inputs: model_name, credentials

* fix: add required validation to input fields
inputs: aws_secret_access_key, aws_access_key_id

* fix: add required validation to input fields
inputs: input_text, match_text

* fix: add required validation to input fields
inputs: input_message

* fix: add required validation to input fields
inputs: input_value

* fix: add required validation to input fields
input: data_input

* fix: add required validation to input fields
inputs: input_value

* fix: add required validation to input fields
input: data_input

* fix: add required validation to input fields
input: data_input

* fix: add required validation to input fields
input: data_input

* fix: add required validation to input fields
input: data_input

* fix: add required validation to input fields

inputs: data_inputs, embeddings

* fix: add required validation to input fields
inputs: api_key, input_value

* fix: add required validation to input fields
inputs: password, username, openai_api_key, prompt

* fix: add required validation to input fields
inputs: api_key, transcription_result

* fix: add required validation to input fields
inputs: api_key, transcription_result, prompt

* fix: add required validation to input fields
input: prompt

* fix: add required validation to input fields
input: api_key

* fix: add required validation to input fields
inputs: api_key, transcript_id

* fix: add required validation to input fields
inputs: audio_file, api_key

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* feat: make YouTube Transcripts URL field required (#5686)

feat: Enhance YouTube Transcripts component by adding required field validation to URL input

This change ensures that users provide a video URL before using the YouTube Transcripts component, preventing potential runtime errors due to missing video source.

* fix: Fix memory leak when creating components (#5733)

Fix memory leak when creating components

* test: Update API key requirements and test configurations for frontend tests (#5752)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: Vinícios Batista da Silva <vinicios.batsi@gmail.com>
Co-authored-by: Raphael Valdetaro <79842132+raphaelchristi@users.noreply.github.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: VICTOR CORREA GOMES <112295415+Vigtu@users.noreply.github.com>
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>

* Updated loop.py component

* [autofix.ci] apply automated fixes

* update test file

* fix: handle None values in input names and improve type hints

* [autofix.ci] apply automated fixes

* Added loop component test

* Added comments

* test: add 'allow_loop' field to Output dictionary in test_output_to_dict method

* fix: correct key name in Output dictionary from 'allow_loop' to 'allows_loop' in test_output_to_dict method

* Updated frontend loop test

* Updated examples

* 🐛 (generalBugs-shard-9.spec.ts): Fix incorrect test selector for chat memory output element
🐛 (loop-component.spec.ts): Fix incorrect test selector for chat output element
🐛 (generalBugs-shard-3.spec.ts): Fix incorrect test selector for open AI model output element

* [autofix.ci] apply automated fixes

* refactor: update return type in AgentComponent to use dotdict for build_config

This change modifies the return statement in the AgentComponent class to utilize a dotdict for the build_config, enhancing the structure and accessibility of the returned configuration data.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Rodrigo Nader <rodrigosilvanader@gmail.com>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: Vinícios Batista da Silva <vinicios.batsi@gmail.com>
Co-authored-by: Raphael Valdetaro <79842132+raphaelchristi@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: VICTOR CORREA GOMES <112295415+Vigtu@users.noreply.github.com>
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
2025-01-21 17:52:28 +00:00
Gabriel Luiz Freitas Almeida
86b83b0f64
fix: make sure tests run async (#5842) 2025-01-21 08:16:33 -08:00
Gabriel Luiz Freitas Almeida
a23be65138
refactor: update component test method and Agent component test for be asynchronous (#5841) 2025-01-21 07:56:06 -08:00
Gabriel Luiz Freitas Almeida
050c12df35
fix: add default models to Anthropic and make sure template is updated (#5839)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-21 07:25:47 -08:00
Vinícios Batista da Silva
349f3441c8
feat: improve model input fields for HuggingFace model component (#5723)
* feat: improve model input fields for huggingface component

1. Make model_id, inference_endpoint and api_token fields required
2. Convert temperature to SliderInput with range 0-2
3. Update temperature info to match HuggingFace's description

Co-authored-by: Vinícios Batista da Silva <vinicios.batsi@gmail.com>

* feat(huggingface): update model selection and temperature input

This commit enhances the HuggingFace component by implementing a fixed list of
large language models in the dropdown selection and improving the temperature
input with a slider control.

Key changes in src/backend/base/langflow/components/models/huggingface.py:
- Add DEFAULT_MODEL constant set to "meta-llama/Llama-3.3-70B-Instruct"
- Replace model_id StrInput with DropdownInput containing pre-selected models:
  * meta-llama/Llama-3.3-70B-Instruct (default)
  * mistralai/Mixtral-8x7B-Instruct-v0.1
  * mistralai/Mistral-7B-Instruct-v0.3
  * meta-llama/Llama-3.1-8B-Instruct
  * Qwen/Qwen2.5-Coder-32B-Instruct
  * Qwen/QwQ-32B-Preview
  * openai-community/gpt2
  * custom option
- Add real_time_refresh to model_id dropdown for dynamic updates
- Implement custom model input field that shows/hides based on selection
- Replace temperature FloatInput with SliderInput for better UX:
  * Added RangeSpec with min=0, max=2, step=0.01
  * Maintains default value of 0.8
- Add build_config update logic to handle custom model visibility
- Update API URL generation to support custom model IDs
- Import RangeSpec and SliderInput from langflow packages

Co-authored-by: Vinícios Batista da Silva <vinicios.batsi@gmail.com>

* [autofix.ci] apply automated fixes

* test(huggingface): update tests for enhanced model selection and UI controls

This commit updates the test suite to verify the new features and changes in
the HuggingFace component, ensuring proper functionality of the model selection
dropdown and improved temperature control.

Key changes in src/backend/tests/unit/components/models/test_huggingface.py:
- Update test_huggingface_inputs to verify new DropdownInput for model_id:
  * Check DEFAULT_MODEL as default value
  * Verify presence of 'custom' option
  * Validate required and real_time_refresh settings
- Add verification for custom_model field:
  * Confirm initial custom_model hidden state
  * Verify required flag
- Add specific checks for temperature SliderInput:
  * Validate default value of 0.8
  * Verify RangeSpec configuration (min=0, max=2, step=0.01)
- Improve test structure with detailed assertions for field configurations
- Update imports to include DEFAULT_MODEL constant

Related to previous commit that enhanced the HuggingFace component with
fixed model list and slider controls.

Co-authored-by: Vinícios Batista da Silva <vinicios.batsi@gmail.com>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-21 01:51:10 +00:00
Ítalo Johnny
00dcef2bf1
feat: implement function to truncate json (#5811)
* feat: implement function to truncate json

* refactor: apply JSON truncation function in models

* fix: update code to use the standard field serialization format

* Update src/backend/base/langflow/services/database/models/transactions/model.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/services/database/models/transactions/model.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/services/database/models/vertex_builds/model.py

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-20 21:15:07 +00:00
Cristhian Zanforlin Lousa
9dc6c24180
feat: change Text to Message type with backend and frontend support (#5652)
*  (inputs.py): Update default prompt input types to include "MessageTextInput" for improved user experience
📝 (styleUtils.ts): Add color definition for "MessageTextInput" node to enhance visual representation in the frontend

* 📝 (text.py): Update input_types for "Value" to include "Message" for better clarity
📝 (memory.py): Update input_types for "Session ID" to include "Message" for consistency
📝 (message.py): Update input_types for "Session ID" to include "Message" for uniformity
📝 (self_query.py): Update input_types for "Query" to only include "Message" for consistency
📝 (create_data.py): Update input_types for fields to only include "Message" for consistency
📝 (update_data.py): Update input_types for fields to only include "Message" for consistency
📝 (inputs.py): Update DEFAULT_PROMPT_INTUT_TYPES to only include "Message" for consistency
📝 (styleUtils.ts): Remove "MessageTextInput" from nodeColors and nodeColorsName for consistency

* 📝 (model.py): update display name from "Text" to "Message" for better clarity
📝 (url.py): update display name from "Text" to "Message" for better consistency
📝 (memory.py): update display name from "Text" to "Message" for better understanding
📝 (text.py): update display name from "Text" to "Message" for better semantics
📝 (llm_math.py): update display name from "Text" to "Message" for improved readability
📝 (runnable_executor.py): update display name from "Text" to "Message" for better context
📝 (sql_generator.py): update display name from "Text" to "Message" for clearer communication
📝 (text.py): update display name from "Text" to "Message" for better consistency
📝 (parse_data.py): update display name from "Text" to "Message" for enhanced understanding
📝 (wikidata_api.py): update display name from "Text" to "Message" for improved semantics
📝 (test_cycles.py): update display name from "Text" to "Message" for better clarity

* [autofix.ci] apply automated fixes

* 🔧 (App.css): change width property value to fit-content to improve layout responsiveness

* fix: resolve merge conflicts and clean up URLComponent implementation in starter projects

- Removed conflicting sections in the JSON files for 'Custom Component Maker' and 'Graph Vector Store RAG'.
- Ensured the URLComponent class is correctly defined with methods for URL validation and content fetching.
- Updated input and output definitions for better clarity and functionality.

* 🐛 (freeze.spec.ts): fix incorrect test selectors for handle-textinput-shownode and handle-parsedata-shownode elements to match updated element IDs

* 📝 (NodeOutputfield/index.tsx): Add id prop to InspectButton component for better identification
🔧 (freeze-path.spec.ts, freeze.spec.ts, stop-building.spec.ts, decisionFlow.spec.ts, similarity.spec.ts, textInputOutput.spec.ts, generalBugs-shard-5.spec.ts, fileUploadComponent.spec.ts): Update test selectors to match changes in UI components for better test accuracy

*  (duckduckgo.spec.ts): update the test to click on a specific element with the test ID "output-inspection-data-duckduckgosearch" instead of "output-inspection-data" to match the updated frontend implementation.

*  (youtube-transcripts.spec.ts): update selector for clicking on transcript element to match changes in the frontend code, ensuring the test remains accurate

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-20 20:36:46 +00:00
Edwin Jose
bbb3987cda
feat: Add model filtering support for Ollama Component, improving stability (#5748)
* Update ollama.py

* ollama models refactor

* ollama embeddings support for model filters

* formatting

* Update src/backend/base/langflow/components/embeddings/ollama.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* [autofix.ci] apply automated fixes

* fix test

* reverting test

* refactor: Update Ollama components to use async URL validation

- Changed `is_valid_ollama_url` method to be asynchronous in both `ollama.py` files.
- Updated calls to `is_valid_ollama_url` to use `await` for proper async handling.
- Modified URL validation logic to ensure compatibility with async operations.
- Improved overall responsiveness of the Ollama components by leveraging async HTTP requests.

* reverting to empty list!

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-20 17:00:40 +00:00
Gabriel Luiz Freitas Almeida
25ca57f53f
tests: Remove unnecessary benchmark markers from server init tests (#5806)
refactor(tests): remove benchmark markers from server init tests

- Removed unnecessary @pytest.mark.benchmark decorators from multiple performance test functions in test_server_init.py.
- This change streamlines the test suite by eliminating redundant benchmarking annotations, while maintaining the integrity of the tests.
2025-01-20 16:43:46 +00:00
VICTOR CORREA GOMES
420cd92faa
feat(component): API Request Component Overhaul (#5007)
* style: Add icon property to WebhookComponent class

* style: Update input components in APIRequest class

* fix pr

* [autofix.ci] apply automated fixes

* remove debug print statement from api_request component

* remove debug print statement from api_request component

* feat: add dynamic cURL mode to APIRequestComponent

- Add cURL command parsing and field population
- Implement dynamic UI updates based on cURL input
- Support JSON body and headers extraction from cURL
- Add real-time refresh for cURL mode toggle

* refactor(APIRequestComponent): improve HTTP methods and cURL handling

- Add DELETE method support
- Enhance cURL parameter handling and UI visibility
- Fix JSON decode error handling with specific exception
- Update method visibility for DELETE requests

* style: Update input components in APIRequest class

* [autofix.ci] apply automated fixes

* remove debug print statement from api_request component

* remove debug print statement from api_request component

* feat: add dynamic cURL mode to APIRequestComponent

- Add cURL command parsing and field population
- Implement dynamic UI updates based on cURL input
- Support JSON body and headers extraction from cURL
- Add real-time refresh for cURL mode toggle

* refactor(APIRequestComponent): improve HTTP methods and cURL handling

- Add DELETE method support
- Enhance cURL parameter handling and UI visibility
- Fix JSON decode error handling with specific exception
- Update method visibility for DELETE requests

* [autofix.ci] apply automated fixes

* git commit -m "ui(api-request): adjust field visibility and requirements

- Move query_params to advanced section
- Make URL field required"

* feat(api): enhance curl parsing and update unit tests

- Improve MultilineInput handling in APIRequestComponent for curl commands
- Update parse_curl unit test to match expected data structure
- Ensure consistent format for headers and body in test assertions

* [autofix.ci] apply automated fixes

* fix(api-request): improve UI/UX and fix initial field visibility

- Fix body field flickering on component load
- Enhance URL/cURL field toggle behavior

*  (filterSidebar.spec.ts): add tests for clicking on edit button modal, show headers button, and closing the modal to ensure correct behavior and visibility of elements

* 📝 (dictComponent/index.tsx): update data-testid attribute to dynamically set based on editNode value for better testability
📝 (nestedComponent.spec.ts): update test data and selectors to match changes in dictComponent/index.tsx for accurate testing

* refactor(api_request): improve component UX and field handling

- Update tool_mode placement to align with main branch changes
- Remove temporary required field validation to prevent UI conflicts
- Add field clearing logic when switching between cURL and URL modes
- Update component description to be more concise

* git commit -m "fix: resolve merge conflicts with upstream in api request component

* fix: resolve merge conflicts with upstream in api request component

* Delete src/backend/tests/unit/test_data_components.py

BREAKING CHANGE: Removed test_data_components.py as it has been replaced by test_api_request_component.py

* git commit -m "test(api-request): update test_parse_curl to match TableInput format

* style(test_api-request): apply ruff formatting rules

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-20 16:23:59 +00:00
anovazzi1
0cf4f03400
fix: Improve error handling in aupdate_messages function to prevent empty message error (#5655)
* refactor: Improve error handling in aupdate_messages function

* Update src/backend/base/langflow/memory.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* fix(tests): updating a non-existing message adds a new message now

- Updated the test name from `test_aupdate_nonexistent_message` to `test_aupdate_nonexistent_message_generates_a_new_message` for better clarity.
- Modified the assertion to expect that a new message is generated when attempting to update a nonexistent message, changing the expected length of the updated messages from 0 to 1.

* [autofix.ci] apply automated fixes

* fix(tests): update message handling in tests for non-existent messages

- Refactored tests to ensure that attempting to update a non-existent message raises a ValueError instead of creating a new message.
- Updated test names and assertions for clarity and accuracy, ensuring they reflect the expected behavior when handling messages that do not exist in the database.

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-20 16:21:19 +00:00
github-actions[bot]
b0325ef2af
chore: update test durations (#5799)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-20 15:54:25 +00:00
Raphael Valdetaro
06139ef2df
refactor(yahoo-finance): Refactor Yahoo Finance API component to support tool mode (#5434)
* refactor(yahoo-finance): Refactor Yahoo Finance API component

* fix(yahoo-finance): Revert method input changes and fix enum error

* fix: update yfinance tool test and remove duplicate method

* fix: rename component class to avoid conflict with legacy version

* [autofix.ci] apply automated fixes

* test: add ToolException import to yfinance tool tests

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-20 15:07:37 +00:00
Gabriel Luiz Freitas Almeida
18e21cfec9
fix: make chat input sorting logic exclude other components (#5760)
* fix: Adjust chat input handling in layer sorting logic

* fix: Update chat input sorting logic and assertions in tests

* [autofix.ci] apply automated fixes

* fix: Update test assertion for chat input sorting to reflect changes in expected output

* [autofix.ci] apply automated fixes

* fix: update vertex sorting logic to handle start_component_id condition

- Modified the condition for sorting layers to include a check for start_component_id being None, ensuring correct behavior when this parameter is not set.
- This change improves the accuracy of the vertex sorting process in the graph utility functions.

* fix: update test assertion for vertex IDs in test_get_vertices

- Modified the test assertion in `test_get_vertices` to reflect the expected output, ensuring it only checks for "ChatInput" in the returned IDs.
- This change improves the accuracy of the test by aligning it with the current expected behavior of the endpoint.

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ítalo Johnny <italojohnnydosanjos@gmail.com>
2025-01-20 13:49:44 +00:00
github-actions[bot]
a800778f70
chore: update test durations (#5790)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-20 12:33:45 +00:00
VICTOR CORREA GOMES
6c79a3d6aa
refactor(tools): overhaul Python REPL component with modern tool mode (#5463)
* refactor(tools): overhaul Python REPL component with modern tool mode

BREAKING CHANGE: Complete redesign of PythonREPL component architecture

- Replace legacy tool mode with modern tool_mode=true implementation
- Add automatic import detection for both global and from-imports
- Remove manual global_imports field in favor of automatic detection
- Implement CodeInput type support with FieldTypes.CODE
- Update schema to handle new parameters for agent compatibility
- Improve error handling and logging for import failures

The component now automatically handles imports without manual configuration,
supports modern tool mode, and provides better integration with the agent
system through updated schema definitions.

* refactor(python-repl): remove name parameter

* feat(security): add required global imports validation

- Add explicit global imports input for security control
- Set both global_imports and python_code as required fields
- Remove AST-based import analysis in favor of explicit imports

* [autofix.ci] apply automated fixes

* fix: remove generic exception handling in python_repl

Removed overly broad exception handling to comply with linting rules.

* fix

* test(python-repl): update component test to match current implementation

- Remove assertions for deprecated outputs (api_run_model, api_build_tool)
- Add assertions for current 'results' output
- Add detailed input validation tests for global_imports and python_code
- Verify input configurations including type, default values, and required status
- Ensure component template structure matches frontend requirements

This change aligns the test suite with the current PythonREPLToolComponent
implementation, improving test coverage and maintaining component reliability.

* revert(tools): restore Python REPL component to original implementation

Due to backward compatibility concerns, reverting the Python REPL component
to its initial implementation state to maintain stability and prevent breaking changes.

* feat(tools): mark Python REPL component as deprecated & Legacy

* feat(tools): add Python REPL Core component

* [autofix.ci] apply automated fixes

* fix(tests): mark Python REPL Core as unreleased component

* fix(__init__): fix

* feat(python-repl): improve example clarity for printing the results

* fix(tests): resolve KeyError in test_component_versions

* style(python-repl): format description string to follow PEP 8 guidelines

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-20 11:54:32 +00:00
Raphael Valdetaro
7f6b924f9c
refactor: Update Serp API component to standard output pattern (#5437)
* refactor: Update Serp API component to standard output pattern

* test: add unit tests for SerpAPIComponent

* [autofix.ci] apply automated fixes

* fix: rename component class to avoid conflict with legacy version

* [autofix.ci] apply automated fixes

* fix: update SerpAPI to extend LCToolComponent

* [autofix.ci] apply automated fixes

* deprecate: mark SerpAPIComponent as legacy and deprecated

* refactor: update Serp API component tests to use new SerpComponent

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-20 07:17:43 +00:00
Gabriel Luiz Freitas Almeida
69dc96039e
feat: limit transaction and vertex build logging with retention policies (#5658)
* feat: implement vertex build logging with maximum retention policy

- Added functionality to log vertex builds while maintaining a maximum number of builds per vertex.
- Introduced a new setting `max_vertex_builds_per_vertex` to configure the retention limit.
- Updated `log_vertex_build` method to delete older entries in a single transaction if the limit is exceeded.
- Enhanced error handling to ensure database integrity during logging operations.

* feat: enhance transaction logging with maximum retention policy

- Implemented functionality to log transactions while maintaining a maximum limit on the number of transactions stored in the database.
- Introduced logic to delete older transactions when the limit is exceeded, ensuring efficient database management.
- Enhanced error handling to maintain database integrity during transaction logging operations.

* feat: enhance vertex build logging with global and per-vertex retention policy

- Updated the log_vertex_build function to maintain a maximum number of vertex builds globally and per vertex.
- Introduced new settings for global maximum builds to keep and per-vertex maximum builds.
- Implemented logic to delete older entries both globally and per vertex in a single transaction, ensuring efficient database management.

* fix: import dependency

* fix: update max_vertex_builds_per_vertex setting to improve build retention policy

- Changed the maximum number of builds per vertex from 5 to 2 to enhance resource management.
- This adjustment aims to optimize database storage and ensure older builds are deleted more efficiently.

* fix: ensure flow_id is a UUID in get_vertex_builds_by_flow_id function

- Added a check to convert flow_id from string to UUID if necessary, improving type safety and preventing potential errors during database queries.

* feat: add test for multiple flow builds and vertex build verification

- Implemented a new asynchronous test to validate that multiple builds of a flow generate the expected number of vertex builds.
- The test includes detailed logging of vertex build states and ensures that the number of builds per vertex adheres to the configured maximum.
- Introduced session ID generation for each request to simulate real-world usage and added delays to maintain request order.
- Enhanced verification logic to assert the correctness of build counts and validity after multiple requests.

* refactor: optimize vertex build deletion logic with CTEs

- Replaced the previous deletion logic in the log_vertex_build function with Common Table Expressions (CTEs) for improved clarity and performance.
- Introduced global and per-vertex ranking CTEs to streamline the process of identifying and deleting older vertex builds based on configured limits.
- This change enhances the efficiency of the database operations while maintaining the existing retention policies for vertex builds.

* [autofix.ci] apply automated fixes

* fix: remove unnecessary db.refresh call in log_vertex_build function

- Eliminated the redundant await db.refresh(table) line in the log_vertex_build function to streamline the deletion process.
- This change improves the efficiency of the function by reducing unnecessary database operations while maintaining the integrity of the vertex build logging logic.

* Revert "refactor: optimize vertex build deletion logic with CTEs"

This reverts commit d741233e5c3fadd79d91fbe246b005f3855300df.

* feat: enhance vertex build retrieval and logging with detailed documentation and retention policies

- Updated the `get_vertex_builds_by_flow_id` function to include comprehensive docstring documentation, clarifying its purpose, arguments, and return values.
- Refined the `log_vertex_build` function to support configurable maximum builds to keep globally and per vertex, with improved transaction handling and error management.
- Added detailed docstrings for both functions to improve code readability and maintainability.
- Ensured that the function handles string to UUID conversion for `flow_id` seamlessly, enhancing type safety.
- This update aims to improve the clarity of the codebase and ensure efficient management of vertex builds in the database.

* feat: add unit tests for vertex build logging and retention policies

- Introduced new test suite for vertex build logging, including tests for basic logging, global and per-vertex limits, integrity error handling, and concurrent logging.
- Implemented fixtures for generating sample vertex build data and mock settings to streamline testing.
- Enhanced tests to verify that the logging mechanism adheres to configured retention policies, ensuring efficient management of vertex builds in the database.
- This addition aims to improve code coverage and ensure the reliability of vertex build functionalities.

* refactor(database): replace direct table column references with col() function for consistency and clarity in query construction

* refactor(database): remove IntegrityError handling in transaction logging functions

- Eliminated the IntegrityError exception handling in the log_transaction and log_vertex_build functions to simplify error management.
- This change streamlines the transaction process by relying on a general exception handler, improving code clarity and maintainability.

* refactor(tests): convert mock_settings fixture to async and utilize asyncio.to_thread for Settings instantiation

- Updated the mock_settings fixture to be asynchronous, improving compatibility with async test cases.
- Replaced direct instantiation of Settings with asyncio.to_thread to ensure non-blocking behavior during tests.
- This change enhances the test suite's performance and aligns with the asynchronous nature of the application.

* refactor(tests): update mock_settings fixture to async for improved test performance

- Converted the mock_settings fixture to an asynchronous function, allowing for better compatibility with async test cases.
- Utilized asyncio.to_thread for the instantiation of Settings, ensuring non-blocking behavior during tests.
- This change enhances the overall performance of the test suite and aligns with the asynchronous architecture of the application.

* fix(tests): correct mock_settings fixture and remove async usage

- Fixed a typo in the import statement for datetime in the test_vertex_builds.py file.
- Changed the mock_settings fixture back to a synchronous function, removing the unnecessary use of asyncio.to_thread for Settings instantiation.
- This update ensures compatibility with the existing test structure while maintaining the intended functionality of the mock settings.

* refactor(tests): streamline vertex build logging test for improved clarity and efficiency

- Consolidated build creation and insertion logic in `test_log_vertex_build_with_different_limits`.
- Enhanced readability by reducing redundancy in build sorting and insertion steps.
- Maintained functionality to ensure limits on total and per-vertex builds are correctly enforced.

This refactor aims to improve the maintainability of the test while ensuring it accurately verifies the logging behavior of vertex builds.

* refactor(tests): comment out failing test for vertex build generation

- Temporarily disable `test_multiple_runs_with_no_payload_generate_max_vertex_builds` due to issues with its execution.
- The test was designed to verify the correct number of vertex builds generated during multiple flow builds but requires further investigation and fixes before re-enabling.

This change aims to maintain test suite stability while addressing underlying issues in the test logic.

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-19 21:24:21 +00:00
VICTOR CORREA GOMES
d650b21f17
refactor(google_serper_api): migrate to new tool mode implementation (#5446)
* # refactor(google_serper_api): migrate to new tool mode implementation

BREAKING CHANGE: Replace legacy LCToolComponent implementation with new Component base class

- Migrate from LCToolComponent to Component base class
- Add tool_mode flag to MultilineInput
- Update output configuration to use DataFrame type
- Implement structured error handling with DataFrame responses
- Remove legacy tool mode implementation

* test(google-serper): add unit tests for GoogleSerperAPIComponent

- Add comprehensive test suite for GoogleSerperAPIComponent
- Mock HTTP requests to test search functionality
- Test component initialization and configuration
- Add error handling test cases
- Test text search and wrapper building methods
- Ensure proper DataFrame output structure

This change improves test coverage for the Google Serper API integration,
following existing test patterns in the project.

* [autofix.ci] apply automated fixes

* style(tests): remove unused fixture argument in google-serper test

- Remove unused mock_search_results fixture from test_text_search_serper
- Fix linting error ARG001 (unused function argument)

* revert(tools): restore Google Search API component to original implementation

Due to backward compatibility concerns, reverting the Google Search API component
to its initial implementation state to maintain stability and prevent breaking changes.

* refactor(components): mark GoogleSerperAPI component as deprecated & Legacy

* feat(components): add GoogleSerperAPICore component

* refactor(google-serper): fix filename typo from 'gloogle' to 'google'

* test(google-serper): add unit tests following component test guide

* feat(icons): improve Serper icon quality and add to icon list

* [autofix.ci] apply automated fixes

* Update test_google_serper_api_core.py

test update

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-18 01:25:34 +00:00
VICTOR CORREA GOMES
7c04245ea1
refactor(google_search): migrate to new tool mode implementation (#5444)
* ## refactor(google_search): migrate to new tool mode implementation

- Replace legacy tool mode using LCToolComponent with new Component class and tool_mode flag.

- Update input/output definitions to use new DataFrame type and explicit Output configuration.

Key changes:
- Migrate from LCToolComponent to Component base class
- Add explicit output configuration with DataFrame type
- Update error handling to return structured DataFrame responses
- Implement tool_mode using new flag syntax

* test(google-search): add unit tests for GoogleSearchAPIComponent

* fix(google-search): adjust DataFrame format to match expected type

- Update error responses to use list[dict] format instead of dict[list]

* [autofix.ci] apply automated fixes

* revert(tools): restore GoogleSearchAPI component to its original implementation

Due to potential breaking changes in the repository, reverting the GoogleSearchAPI
component to its initial state to maintain compatibility and stability.

* refactor(tools): mark GoogleSearchAPI component as deprecated

Mark GoogleSearchAPI component as legacy and add [DEPRECATED] to its display name
to better communicate its status to users while maintaining backward compatibility.

* feat: add Google Search API core component

Implements Google Search API wrapper with error handling and DataFrame output

* test: update Google Search API tests for core component

Adjusts test file to use GoogleSearchAPICore instead of GoogleSearchAPIComponent

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-18 00:14:38 +00:00
Rodrigo Nader
8d902e6c74
feat: Add ParseDataFrameComponent for DataFrame-to-text conversion with tests (#5594)
* add dataframe outputs to vector stores, directory, url, split text

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* add parse dataframe

* [autofix.ci] apply automated fixes

* Refactor: Update DataFrame handling in components

- Added import of DataFrame in directory and url components.
- Renamed variable 'df' to 'dataframe' in ParseDataFrameComponent for clarity.
- Updated method _clean_args and parse_data to use 'dataframe' instead of 'df' for consistency.

These changes enhance code readability and maintainability by standardizing the terminology used for DataFrame objects.

* [autofix.ci] apply automated fixes

* remove parse dataframe

* feat: add parse dataframe component

* [autofix.ci] apply automated fixes

* Refactor: Remove duplicate as_dataframe method in LCVectorStoreComponent

This commit eliminates the redundant as_dataframe method in the LCVectorStoreComponent class, streamlining the code and improving maintainability. The method was previously defined twice, and this change enhances clarity by ensuring only one implementation exists.

* [autofix.ci] apply automated fixes

* Refactor: Standardize DataFrame variable naming in ParseDataFrameComponent

This commit renames the variable 'df' to 'dataframe' in the ParseDataFrameComponent class to improve clarity and consistency. The changes are reflected in the _clean_args and parse_data methods, enhancing code readability and maintainability.

* test: add unit tests for ParseDataFrameComponent

This commit introduces a comprehensive suite of unit tests for the ParseDataFrameComponent, covering various scenarios including successful parsing with default and custom templates, handling of empty dataframes, invalid template keys, and performance on large dataframes. The tests ensure that the component behaves correctly with different data types and separators, and validate its functionality in both synchronous and asynchronous contexts. These additions enhance the reliability and maintainability of the component.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-17 23:41:42 +00:00
Edwin Jose
040a84ed52
feat: run flow component with tool mode option to run a flow as a tool (#5518)
* Update calculator.py

* Update json_cleaner.py

* [autofix.ci] apply automated fixes

* updated init

* updated format

format

* update component

sample component update

* Update flow_orchestrator.py

* test files

tests

* update in flow Orchestrator

* Update flow_orchestrator.py

solves issues with agents and session ids

* Update flow_orchestrator.py

* update to FlowOrchetstor

update to FlowOrchetstor

* draft Commit

* updated to run_flow

* updates

* refactor code

* [autofix.ci] apply automated fixes

* default_name of tool to be the name of the flow

* add tool_mode default activation

* [autofix.ci] apply automated fixes

* updates to build schema

* [autofix.ci] apply automated fixes

* update to schema and run flow

* cleanup

* Update run_flow.py

* [autofix.ci] apply automated fixes

* fix(run_flow.py): update condition to check if field_order exists in field_template for improved input validation

* Update run_flow.py

* [autofix.ci] apply automated fixes

* debug updates

* updates in flow tool outputs and tool mode

* code cleanup

* Update component_tool.py

* Update run_flow.py

* updated description

added beta tag as per Simons Suggestion

* [autofix.ci] apply automated fixes

* Update component_tool.py

* Update schema.py

* [autofix.ci] apply automated fixes

* feat: Add ToolModeMixin to CodeInput class

* Update component.py

* updated tests

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-17 23:12:56 +00:00
VICTOR CORREA GOMES
3474259ca4
refactor: Calculator Component updating tool implementation and fix deprecation warnings (#5442)
* refactor(calculator): update tool implementation

Replace legacy tool mode implementation using CalculatorToolSchema with simplified tool_mode=True approach.

* refactor(calculator): fix deprecation warnings

Fix ast.Num deprecation warnings by supporting ast.Constant while maintaining backwards compatibility.

* Update isinstance check to use Python 3.10+ union operator (|) instead of tuple syntax

* Update calculator.py

Component name required; if not it would get None in Toolset

* [autofix.ci] apply automated fixes

* test(calculator): add unit tests for CalculatorToolComponent

* revert(tools): restore Calculator component to its original implementation

Due to potential breaking changes in the repository, reverting the Calculator
component to its initial PR state to maintain compatibility and stability.

* feat(tools): mark Calculator component as legacy and update display name

- Set legacy flag to true for Calculator component
- Update display name to "Calculator (Deprecated)" to clearly indicate deprecation status
- Maintain backward compatibility by preserving class name and internal name

* feat(tools)!: add new calculator core component

BREAKING CHANGE: Introduces calculator_core.py as a replacement for the deprecated calculator.py

* refactor(tools): rename calculator classes for better distinction

* refactor(tools): update __init__.py to reflect new class names

* [autofix.ci] apply automated fixes

* test(tools): update calculator tests for core component

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-17 20:55:12 +00:00
Raphael Valdetaro
656f9f30db
feat: Add DeepSeek Model component (#5443)
* feat: Add DeepSeek component

* Adiciona DeepseekModelComponent ao __init__.py

* [autofix.ci] apply automated fixes

* Add DeepSeek icon and update component files

* Add DeepSeek icon and update all related files

* [autofix.ci] apply automated fixes

* Change DeepSeek icon color to blue (#080c34)

* [autofix.ci] apply automated fixes

* Revert DeepSeek icon color to black

* [autofix.ci] apply automated fixes

* remove: name parameter from DeepSeekModel to avoid backwards compatibility issues

* test: add unit tests for DeepSeek model component with mocks

* fix: correct formatting issues in DeepSeek model tests

* feat: update DeepSeek icon color to #4c6cfc

* fix: make DeepSeek API key field required

* fix: format SecretStrInput to comply with line length limit in DeepSeekModelComponent

* feat: add dark mode support for component icon

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-17 17:45:39 +00:00
Cristhian Zanforlin Lousa
c39bb39772
fix: pass slider input values correctly, add test (#5735)
*  (base.py): Update field validation to include "slider" type in addition to "float" type for better parameter handling
📝 (constants.py): Add "slider" type to the list of DIRECT_TYPES for consistency and completeness

*  (test_inputs.py): add unit test for SliderInput class to ensure it initializes with correct value

* 🐛 (base.py): fix comparison of field type with a list by changing it to a set to ensure correct condition evaluation

* [autofix.ci] apply automated fixes

* fix format

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-16 18:41:17 +00:00
Gabriel Luiz Freitas Almeida
99f2ef6115
feat: add truncation to ResultDataResponse (#5704)
* chore: Update dependencies and improve platform markers in configuration files

- Added 'hypothesis' version 6.123.17 to dev-dependencies in pyproject.toml.
- Updated platform markers from 'sys_platform' to 'platform_system' for better compatibility in uv.lock, affecting multiple packages including 'jinxed', 'colorama', and 'appnope'.
- Ensured consistency in platform checks across various dependencies to enhance cross-platform support.

This update improves the project's dependency management and ensures better compatibility across different operating systems.

* feat: Enhance ResultDataResponse serialization with truncation support

- Introduced a new method `_serialize_and_truncate` to handle serialization and truncation of various data types, including strings, bytes, datetime, Decimal, UUID, and BaseModel instances.
- Updated the `serialize_results` method to utilize the new truncation logic for both individual results and dictionary outputs.
- Enhanced the `serialize_model` method to ensure all relevant fields are serialized and truncated according to the defined maximum text length.

This update improves the handling of large data outputs, ensuring that responses remain concise and manageable.

* fix: Reduce MAX_TEXT_LENGTH in constants.py from 99999 to 20000

This change lowers the maximum text length limit to improve data handling and ensure more manageable output sizes across the application.

* test: Add comprehensive unit tests for ResultDataResponse and VertexBuildResponse

- Introduced a new test suite in `test_api_schemas.py` to validate the serialization and truncation behavior of `ResultDataResponse` and `VertexBuildResponse`.
- Implemented tests for handling long strings, special data types, nested structures, and combined fields, ensuring proper serialization and truncation.
- Enhanced coverage for logging and output handling, verifying that all fields are correctly processed and truncated as per the defined maximum text length.
- Utilized Hypothesis for property-based testing to ensure robustness and reliability of the serialization logic.

This update significantly improves the test coverage for the API response schemas, ensuring better data handling and output management.
2025-01-16 18:39:34 +00:00
github-actions[bot]
90f570edd4
chore: update test durations (#5736)
Co-authored-by: ogabrielluiz <24829397+ogabrielluiz@users.noreply.github.com>
2025-01-16 11:06:14 -08:00
Raphael Valdetaro
d89f8e8e18
refactor: Refactor Wikipedia API component (#5432)
* refactor(wikipedia): Refactor Wikipedia API component

* test: add unit tests for WikipediaAPIComponent

* [autofix.ci] apply automated fixes

* refactor: improve WikipediaAPIComponent tests and fix lint issues

* [autofix.ci] apply automated fixes

* fix: resolve lint issues in WikipediaAPIComponent tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
2025-01-16 18:37:26 +00:00
Gabriel Luiz Freitas Almeida
0ddc310122
ci: limit test duration update to unit tests and allow to continue on error (#5730)
* fix: update pytest command to target unit tests directory in GitHub Actions workflow

Modified the command in the store_pytest_durations.yml workflow to run pytest on the 'unit' tests directory instead of the 'backend' tests directory, ensuring more accurate duration tracking for unit tests.

* ci: update GitHub Actions workflow to improve pytest execution

Modified the store_pytest_durations.yml workflow to enhance the pytest command execution by removing the retry action and adding an ID for better tracking. The command now runs directly with the option to continue on error, ensuring that test durations are accurately recorded without unnecessary retries.

* refactor: update test durations and improve pytest tracking

This commit modifies the test duration tracking in the `.test_durations` file, reflecting updated execution times for various unit tests. The changes include adjustments to the duration values for multiple test cases across different modules, ensuring more accurate performance metrics. This update aims to enhance the reliability of test duration reporting in the CI pipeline.
2025-01-16 16:13:26 +00:00
anovazzi1
f4fca2b6bb
Fix: update tweaks processing to allow input_type without input_value (#5656)
* fix: tweaks processing in api usage

* refactor code

* fix: unit tests

* Refactor input handling in simple_run_flow function

* Refactor input handling in test_endpoints.py

---------

Co-authored-by: Ítalo Johnny <italojohnnydosanjos@gmail.com>
2025-01-15 20:43:19 +00:00
Christophe Bornet
da83dbbcb5
feat: Bump ruff version to 0.9 (#5666)
* Bump ruff version to 0.9

* Rename some modules for A005 ruff rule
2025-01-15 15:14:43 +00:00
Phil Miesle
f85d447748
fix: address api_request issues on Python 3.11+ (#5643)
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-13 05:19:46 -08:00
Phil Miesle
517961d281
fix: problem with saving files from APIRequestComponent (#5627)
* fix problem with saving files from APIRequestComponent

* moving api_request component test to appropriate subdir
2025-01-10 18:22:04 +00:00
Rodrigo Nader
45ed8e5e54
feat(dataframe): add support for DataFrame outputs across multiple components (#5589)
* add dataframe outputs to vector stores, directory, url, split text

* add dataframe import

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* add parse dataframe

* [autofix.ci] apply automated fixes

* Refactor: Update DataFrame handling in components

- Added import of DataFrame in directory and url components.
- Renamed variable 'df' to 'dataframe' in ParseDataFrameComponent for clarity.
- Updated method _clean_args and parse_data to use 'dataframe' instead of 'df' for consistency.

These changes enhance code readability and maintainability by standardizing the terminology used for DataFrame objects.

* [autofix.ci] apply automated fixes

* remove parse dataframe

* Add tests for URL component functionality and data handling

* Enhance DirectoryComponent tests with new functionality and parameters

- Added tests for loading files with specific types and handling hidden files.
- Implemented tests for directory loading with depth and multithreading support.
- Introduced a new test for converting directory contents to a DataFrame.
- Updated existing tests to include additional parameters like 'silent_errors' and 'types'.

These changes improve test coverage and ensure the DirectoryComponent behaves as expected under various conditions.

* update retrieve_file_paths for backwards compatibility

* Refactor DirectoryComponent to handle file types more robustly

- Removed the default assignment of TEXT_FILE_TYPES to 'types' and added logic to use all supported types if none are specified.
- Implemented validation to ensure only valid file types are processed, improving error handling.
- Updated the file retrieval process to utilize the filtered list of valid types.

These changes enhance the flexibility and reliability of the DirectoryComponent's file loading functionality.

* Refactor and simplify tests in test_data_components.py

- Removed multiple tests related to HTTP requests, including successful and failed GET requests, timeouts, and multiple URL handling, to streamline the test suite.
- Cleaned up imports and unnecessary mock setups to enhance readability and maintainability.
- Focused on retaining essential tests for DirectoryComponent and URLComponent functionality, ensuring core features are still validated.

These changes improve the clarity and efficiency of the test suite while maintaining coverage for critical components.

* Add unit tests for DirectoryComponent functionality

- Introduced a new test file for DirectoryComponent, enhancing test coverage.
- Implemented various tests to validate loading files with specific types, handling hidden files, and supporting multithreading.
- Added tests for directory loading with depth and converting directory contents to a DataFrame.
- Ensured tests cover different scenarios, including recursive loading and file type filtering.

These changes improve the robustness and reliability of the DirectoryComponent's functionality through comprehensive testing.

* Add unit tests for URLComponent functionality

- Introduced a new test file for URLComponent, enhancing test coverage for its methods.
- Implemented tests for fetching content from valid URLs, handling multiple URLs, and validating error handling for invalid URLs.
- Added tests for converting fetched content to a DataFrame and ensuring correct message formatting.
- Mocked web requests to simulate various scenarios, ensuring robust testing of URLComponent's functionality.

These changes improve the reliability and correctness of the URLComponent through comprehensive testing.

* Add unit tests for SplitTextComponent functionality

- Introduced a new test file for SplitTextComponent, enhancing test coverage for its methods.
- Implemented tests for basic text splitting, handling overlaps, custom separators, and preserving metadata.
- Added tests for converting split text results to a DataFrame and handling empty input.
- Ensured functionality for single and multiple input texts is validated.

These changes improve the reliability and correctness of the SplitTextComponent through comprehensive testing.

* Add comment to ignore FBT001 in retrieve_file_paths function

* Validate specified file types in DirectoryComponent and raise ValueError for invalid types

* Fix type hint in DataFrame constructor to support list of dicts or Data objects. This change enhances type safety and clarity in the DataFrame initialization process.

* Enhance DirectoryComponent tests to validate error handling for invalid file types

- Removed the test case for 'exe' file type from valid scenarios.
- Added a new test to ensure DirectoryComponent raises a ValueError for invalid file types, specifically when 'exe' is specified.
- Improved test coverage for DirectoryComponent by validating error messages for unsupported file types.

These changes strengthen the reliability of the DirectoryComponent by ensuring proper error handling for invalid inputs.

* [autofix.ci] apply automated fixes

* Update error handling in Component class to return None for missing flow_id or session_id

- Modified the send_error_message method to include a type hint that allows for returning None in addition to Message.
- Added a conditional check to return None if flow_id or session_id is not present, improving robustness in error handling.

These changes enhance the reliability of the Component class by ensuring it gracefully handles cases with missing identifiers.

* Refactor error handling in Component class to return None for missing session_id

- Updated the send_error_message method to remove the flow_id check, simplifying the logic.
- Enhanced robustness by ensuring that the method returns None if session_id is not present.

These changes improve the reliability of the Component class in handling error messages.

* Update required_inputs for DataFrame method in JSON configurations

- Modified the 'required_inputs' field for the 'DataFrame' method in both 'Graph Vector Store RAG.json' and 'Vector Store RAG.json' files to include necessary parameters: 'api_endpoint', 'collection_name', and 'token'.
- In 'Vector Store RAG.json', added 'collection_name_new' to the 'required_inputs' list.

These changes ensure that the DataFrame method has the appropriate inputs defined for proper functionality.

* [autofix.ci] apply automated fixes

* Enhance BaseComponent to use deep copy for attribute values in template configuration

- Updated the BaseComponent class to utilize `copy.deepcopy` when assigning values to `template_config`. This change ensures that modifications to the original component's attributes do not affect the template configuration, enhancing data integrity and preventing unintended side effects.

These changes improve the reliability of the BaseComponent by ensuring that the template configuration remains consistent and isolated from the original component's state.

* Added output for 'dataframe' in both ingestion and rag graphs

- Updated the ingestion vector store ID for better identification.
- Added output for 'dataframe' in both ingestion and rag graphs to enhance data handling.
- Simplified the output assignment for search results in rag graph by using a data list.

These changes improve the test structure and ensure that the vector store components are correctly configured for better testing outcomes.

* Refactor vector store RAG tests for improved validation and consistency

- Updated test assertions in `test_vector_store_rag_dump_components_and_edges` to verify the expected number of nodes and their types using a mapping for easier lookup.
- Changed the ingestion vector store ID from `vector-store-123` to `ingestion-vector-store-123` for better identification.
- Adjusted expected edges in the tests to reflect the new vector store ID, ensuring accurate edge validation.

These changes enhance the test structure and ensure that the vector store components are correctly configured for better testing outcomes.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-10 14:50:30 +00:00
Gabriel Luiz Freitas Almeida
9c23759c7d
refactor: add graph utility tests and refactor sorting methods (#5538)
* refactor: turn sorting methods into functions in a separate module

- Added `layered_topological_sort` function to perform layered topological sorting of graph vertices, accommodating cycles and input vertex checks.
- Introduced `refine_layers` function to ensure proper dependency ordering among vertices.
- Implemented helper functions for sorting layers by dependency and filtering vertices based on predecessors.
- Enhanced utility functions to support better graph traversal and layer management.

This update improves the graph processing capabilities, allowing for more efficient handling of complex graph structures.

* feat(tests): enhance graph utility tests with cycle detection and sorting functionality

- Added a new fixture `graph_with_loop` to simulate a graph containing cycles for testing purposes.
- Improved the `test_large_graph_efficiency` to validate cycle detection in large graphs.
- Introduced multiple tests for sorting vertices in graphs with cycles, ensuring correct order and handling of input vertices.
- Enhanced assertions to provide clearer error messages for failed tests, improving debugging experience.

These changes strengthen the testing framework for graph utilities, ensuring robust handling of complex graph structures.

* refactor(graph): remove unused parent_node_map from Graph class initialization

- Eliminated the `parent_node_map` parameter from the Graph class constructor, streamlining the graph initialization process.
- This change enhances code clarity and reduces unnecessary complexity in graph management.

This update contributes to cleaner and more maintainable graph-related code.

* refactor(graph): optimize dependency sorting and vertex filtering

- Improved the `_max_dependency_index` function by utilizing `index_map.get()` for cleaner code and better handling of missing successors.
- Enhanced the `_sort_single_layer_by_dependency` function with a caching mechanism to avoid redundant calculations, improving performance during vertex sorting.
- Updated `filter_vertices_up_to_vertex` to use a set for `vertices_ids`, optimizing membership checks and enhancing efficiency in vertex filtering.

These changes contribute to more efficient graph processing and improved code readability.

* chore: remove unused 'parent_node_map' parameter

* [autofix.ci] apply automated fixes

* fix: replace old method call with a new func

* test: enhance assertions for file existence in webhook tests

* refactor(graph): enhance component ID retrieval and chat input sorting

- Updated `find_start_component_id` to accept an optional `is_webhook` parameter, allowing for dynamic priority input selection based on the flow type.
- Improved `sort_chat_inputs_first` to handle chat input positioning more efficiently, ensuring only one chat input exists and adjusting its position within the layers as needed.
- These changes enhance the flexibility and efficiency of graph processing, particularly for webhook flows.

* test(graph): update assertions in sort_chat_inputs_first test for accuracy

- Modified assertions in the `test_chat_inputs_at_start` function to reflect the correct expected output of the `sort_chat_inputs_first` utility.
- Adjusted the expected length and order of the result to ensure accurate validation of chat input sorting functionality.

These changes enhance the reliability of the test suite for graph utilities, ensuring that the sorting logic is correctly validated.

* test(chat): update assertion in consume_and_assert_stream for accurate ID validation

- Modified the assertion in the `consume_and_assert_stream` function to include an additional expected ID, ensuring the test accurately reflects the current output of the chat endpoint.
- This change enhances the reliability of the test suite by validating the correct behavior of the chat input sorting functionality.

* test(endpoints): update assertion in test_get_vertices for accurate ID validation

- Modified the assertion in the `test_get_vertices` function to include an additional expected ID, "Webhook", alongside "ChatInput".
- This change ensures the test accurately reflects the current output of the endpoint, enhancing the reliability of the test suite for endpoint functionality.

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-09 20:15:24 +00:00
Raphael Valdetaro
249f000d12
feat(component): enhance chat input component (#5131)
* feat(component): enhance chat input component

- Replace MultilineInput with StrInput for better text handling
- Remove input handle for cleaner playground integration
- Maintain image support through FileInput
- Keep essential styling and session management options

* refactor(chatinput): keep MultilineInput with empty input_types

Keep MultilineInput for text composition advantage but hide the handle
for UI cleanliness by setting input_types=[].

This preserves the multiline functionality while improving the visual
interface by removing the unnecessary connection handle.

* [autofix.ci] apply automated fixes

* refactor: Update test_cycle_in_graph_max_iterations to use TextInputComponent instead of ChatInput

- Replaced ChatInput with TextInputComponent in test_cycle_in_graph_max_iterations.
- Updated related method calls to reflect the change in component type.
- Ensured that the graph's run queue correctly references the new input component.

* [autofix.ci] apply automated fixes

* Fix type mismatch in cycle test and skip OpenAI-dependent tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
2025-01-09 16:40:18 +00:00
Rodrigo Nader
75c3c1ce97
feat: add batch run beta component (#5489)
* feat: add batch run beta component

* [autofix.ci] apply automated fixes

* Update batch_run to run async using Runnable

* [autofix.ci] apply automated fixes

* refactor: streamline BatchRunComponent by removing unused synchronous model invocation and enhancing async processing

- Consolidated imports and improved type checking for LanguageModel.
- Simplified the run_batch method by directly using the model's asynchronous capabilities.
- Enhanced error handling for missing DataFrame columns.
- Cleaned up comments and improved code readability.

* refactor: update BatchRunComponent to use Runnable for improved async processing

- Added future annotations for better type hinting.
- Replaced LanguageModel with Runnable in type checking and method implementation.
- Enhanced code clarity and maintainability by consolidating imports.

* test: add unit tests for BatchRunComponent functionality

- Introduced a new test suite for BatchRunComponent to validate its behavior.
- Added tests for successful batch runs with and without system messages.
- Implemented tests for handling invalid column names and empty DataFrames.
- Included a test to ensure non-string columns are converted to strings during processing.

* refactor: rename useful.py to mock_language_model.py and update imports

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2025-01-08 19:49:11 +00:00
Christophe Bornet
6b0435906f
feat: Add support for loading flows and components from URLs (#5020)
* Add support for loading flows and components from a zip

* Translate github URLs automatically
2025-01-08 15:31:20 +00:00