16 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
30c2fc159f |
fix: Use relative paths for data files in unit tests (#6021)
Use relative paths for data files in unit tests Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> |
||
|
|
1e4594ad43 |
feat: Implement tool mode functionality and dynamic placeholders across input components (#4402)
* Update content_blocks initialization and add flow_id parameter to ErrorMessage
* feat: include vertex ID in class instantiation
Pass the vertex ID to the custom component during instantiation to facilitate event tracking or management capabilities.
* fix: update message streaming logic to handle None messages and refactor _stream_message parameters
* feat: include flow_id in ChatOutput initialization
Add flow_id to the ChatOutput class to improve the tracking of conversational flows, enhancing the context management within the chat system.
* fix: update chat message source display to use 'source' instead of 'display_name'
* feat: add flow_id to message initialization in ChatOutput class
* fix: handle JSON parsing with type checks for message properties
Refine JSON loading to ensure proper type handling for message properties and content blocks, enhancing stability and preventing potential errors with non-string inputs.
* refactor: update logging structure and message handling
Improve the output logs to support logging multiple entries and ensure robust message streaming with type checking. Adjust error handling parameters for consistency.
* feat: restrict event types in registration and sending
Enhance event management by explicitly defining allowed event types, improving code clarity and reducing potential errors. This ensures only valid event types are registered and sent, leading to more robust event handling.
* Update `logs` attribute to store lists of `Log` objects in `Vertex` class
* feat: introduce TypedDicts for ContentBlock and Properties, update default values in Message model
* fix: restrict event types in send_event method to improve data validation
* Set default values for 'id', 'display_name', and 'source' fields in Source schema
* [autofix.ci] apply automated fixes
* fix: update query to use equality check for error messages
* make lint
* update simple agent test
* test: enhance EventManager tests for event_id validation
* feat: add background, chat icon, and text color properties to component toolkit
* fix: update LogComponent name to display_name for consistency
* remove playground from new cards on main page
* refactor: Update Properties handling in MessageTable and remove unused PropertiesDict
* fix: Set default value for category in MessageBase model
* fix: Update properties default factory in MessageTable model to use model_dump
* Add _build_source method to ChatOutput and update test inputs to use Message objects
* Fix incorrect parameter names in _build_source method across multiple JSON files
* ✅ (freeze.spec.ts, playground.spec.ts, stop-building.spec.ts, linkComponent.spec.ts, sliderComponent.spec.ts, tableInputComponent.spec.ts, stop-button-playground.spec.ts, generalBugs-shard-7.spec.ts): enable tests that were previously skipped to ensure proper functionality and coverage. Remove outdated comments and update test descriptions for clarity.
* Refactor agent event processing to support message streaming and improve content handling
* Refactor ChatOutput to enhance message handling and streamline property assignment
* Fix session ID assignment in send_message method for better message handling
* Add OnTokenFunctionType protocol for enhanced token handling
* Add BorderTrail component for animated border effects
* Add ContentBlockDisplay component for enhanced content visualization and loading state
* Refactor TextShimmer to use motion.create for improved component animation
* Add ContentBlockDisplay to render chat content blocks in newChatMessage component
* Refactor `ChatOutput` class to use `MessageInput` instead of `MessageTextInput` for `input_value` across starter projects.
* Update edge class name from 'runned' to 'ran' in flow components and store
* Add 'on_build_start' and 'on_build_end' events to EventManager
* Add build status updates for 'build_start' and 'build_end' events in buildUtils.ts
* Integrate event management for output function in ComponentToolkit to track build start and end events
* Refactor event handling in ComponentToolkit to improve build event tracking
* Refactor messagesStore to update existing message if it already exists
* update properties to have state attribute
* format
* Refactor chatMessage component to display loading state for partial chat messages
* Refactor reactflowUtils to handle broken edges with missing display names
* fix agent text output
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* fix agent component initialization
* Enhance error message formatting to include detailed exception information
* Refactor agent component for improved performance and stability
* Refactor `LCAgentComponent` to streamline agent execution logic and remove redundant methods
* Add type casting for send_message function in agent.py
* Change return type of function to 'Message' in log schema
* Add `embedding_service` and `client` fields to JSON configurations and refactor ChatOutput class
- Introduced `embedding_service` field in `Vector Store RAG.json` and `Travel Planning Agents.json` to support Astra Vectorize and embedding model selection.
- Added `client` field to `OpenAIEmbeddingsComponent` in JSON configurations for enhanced client configuration.
- Refactored `ChatOutput` class across multiple JSON files to include a new `_build_source` method for constructing `Source` objects, improving code modularity and readability.
- Updated import paths for `OpenAIEmbeddings` to reflect changes in the module structure.
* Update attribute handling in Component class to merge inputs with existing attributes
* Update ChatInput and ChatOutput initialization to include session_id
* Refactor test_load_flow_from_json_object to be asynchronous
* Add asynchronous tests for agent event handling in test_agent_events.py
* Add event handling functions for agent tool and chain events
- Implement functions to handle various agent events such as `on_chain_start`, `on_chain_end`, `on_tool_start`, `on_tool_end`, and `on_tool_error`.
- Introduce helper functions to build content blocks for agent messages.
- Create mappings for chain and tool event handlers.
- Refactor `process_agent_events` to utilize the new event handling functions.
- Remove the old `process_agent_events` implementation from `agent.py` and import the new one from `events.py`.
* feat: update content structure and validation logic
Enhance content block to accept a list of contents instead of a single item, and implement validation to ensure proper format. Refactor tool-related content types for improved clarity and functionality.
* Handle ValidationError in error message generation and update import paths
* feat: enhance error event creation to include structured error content
* move validators and remove utils.py
* feat: add event handler tests for agent tool and chain events
* refactor: streamline tool content structure
Combine multiple tool-related types into a single, more flexible interface. This simplifies the content handling by allowing optional properties for output, error, and timestamp, enhancing overall code maintainability. Adjust the ContentBlock interface to accommodate an array of contents for improved flexibility.
* feat: refactor error handling in ChatMessage component to support dynamic content blocks
* feat: enhance ContentBlockDisplay to support Markdown rendering and dynamic content handling
* Refactor agent event handling to simplify content block management
* Enhance `ContentBlockDisplay` with separators and improved content rendering logic
* add inline block to prevent text overflow in reason
* Refactor code to enhance Markdown rendering and dynamic content handling in ChatMessage component
* [autofix.ci] apply automated fixes
* Add timestamp field to BaseContent class and remove from ToolContent class
* Update timestamp validation to include fractional seconds in BaseContent class
* Add duration calculation for agent and tool events in events.py
* Refactor ContentBlock to use Pydantic's Discriminator and Tag for content types
* Add field validators for content_blocks and properties in Message class
* Add field serializer for source in Properties class
* Add type hint for serialize_properties method in MessageTable class
* create duration component and refactor contents
* [autofix.ci] apply automated fixes
* Refactor duration calculation to use perf_counter for improved accuracy and update ContentBlockDict to use dict for contents
* Update properties field validator to use 'before' mode for improved validation
* Refactor MessageTable to use ContentBlock instead of ContentBlockDict and enhance validation and serialization for properties and content_blocks
* Refactor AgentComponent to streamline agent initialization by using the set method directly
* Refactor event handling functions to use synchronous definitions and improve performance with asyncio.to_thread
* Refactor PythonREPLToolComponent to raise ToolException on error instead of returning error message
* Refactor CalculatorToolComponent to enhance error handling by raising ToolException and improving expression evaluation feedback
* Fix TextShimmer width in ContentBlockDisplay for improved layout consistency
* Enhance ContentBlockDisplay to support external links and math rendering in Markdown
* Enhance error handling in Calculator and Python REPL tools by introducing `ToolException` and improving expression evaluation logic.
* Refactor agent message properties to remove unnecessary icons and update content block titles for clarity
* feat: enhance agent and tool content messaging
Add headers to agent and tool content messages for better clarity and user experience.
* Handle nested schema structure in ContentBlock initialization
* fix: update agent input text content return type and enhance error message formatting
* Add placeholder and default value for model selection in AstraVectorStoreComponent
* Refactor event handling functions to remove `send_message_method` parameter and streamline message processing logic.
* Add model configuration to ToolContent for alias population
* Refactor agent event tests to improve message handling and content block initialization
* test: Update test durations for performance metrics
Adjust the recorded execution times for various test cases to ensure accurate performance tracking and facilitate optimization efforts.
* Refactor test_load_flow_from_json_object to improve project loading logic
* Make `HeaderDict` fields optional and update `header` field in `BaseContent`
* Enhance `Message` and `ChatOutput` with additional attributes for testing
* Update test duration metrics in .test_durations file
* Refactor `ContentDisplay` component to support multiple content types and improve rendering logic
* feat: Enhance duration display with human-readable format
Integrate the pretty-ms library to convert duration display metrics into a more user-friendly format, improving the overall user experience. Update dependencies to ensure compatibility with the latest version and optimize for newer Node.js versions.
* feat: Add optional duration and header properties to BaseContent interface
* fix: Change duration type from float to int in BaseContent class
* Remove default value for 'start_time' in duration calculations
* Enhance `ContentBlockDisplay` with dynamic header and expand/collapse animation
- Added `state` prop to `ContentBlockDisplay` to dynamically set header icon and title based on content state.
- Implemented `renderContent` function to encapsulate content rendering logic with animation.
- Integrated `ForwardedIconComponent` for displaying header icons.
- Updated `newChatMessage.tsx` to pass `state` prop to `ContentBlockDisplay`.
* Add animation to header title using AnimatePresence and motion components
* Add support for processing zip files with multithreading in FileComponent
- Enhanced FileComponent to handle individual and zipped text files.
- Introduced multithreading option for parallel processing of files within zip archives.
- Updated supported file types to include zip files.
- Improved error handling and logging for file processing.
* Expand `Message` conversion to support `AsyncIterator` and `Iterator` types.
* Remove unused function _find_or_create_tool_content from events.py
* Add header information to tool content and streamline message sending in event processing
* Add send_message_method parameter to event handlers for message dispatching
- Updated event handler functions to include a new parameter, `send_message_method`, allowing for message dispatching within the handlers.
- Modified the logic in each handler to utilize the `send_message_method` for sending messages.
- Adjusted the main event processing logic to pass the `send_message_method` to the appropriate handlers.
* Refactor ContentBlockDisplay component to improve rendering performance and user experience
* Refactor `ContentBlockDisplay.tsx` to improve readability and update header title logic
* [autofix.ci] apply automated fixes
* Add 'start_time' to event data and update test functions to include send_message mock
* Refactor ContentBlockDisplay component to include total duration and improve user experience
* Refactor ContentBlockDisplay component to handle isLoading state for total duration calculation
* Refactor animatedNumbers component and add AnimatedNumberBasic component
- Refactor the animatedNumbers component to improve readability and update the header title logic.
- Add a new component called AnimatedNumberBasic that displays an animated number with a specific value.
* Refactor agent message creation to improve event processing efficiency
* Refactor session ID assignment in run_graph_internal for improved clarity
* [autofix.ci] apply automated fixes
* fix: update agent message properties handling for improved compatibility
* fix: enhance message property validation to support dictionary input
* Add session_id to agent message initialization in tests
- Updated test cases in `test_agent_events.py` to include `session_id` in the `Message` initialization.
- Adjusted calls to `process_agent_events` to pass the `agent_message` with `session_id`.
* feat: Enhance event handling with duration tracking
Add start_time parameter to event handling functions to ensure consistent duration calculations across different stages of agent processing. This improves accuracy in measuring event durations and enhances overall event management.
* Add optional humanized value to AnimatedNumber component and update DurationDisplay usage
* Refactor `ContentDisplay` and add separator to `ContentBlockDisplay` component
* Add header to text content in agent message events
* Add separator between each content block in ContentBlockDisplay component
* Refactor layout in ContentDisplay component for improved styling and positioning
* Refactor event handlers to return updated start_time and agent_message
- Modified event handler functions to return a tuple of `agent_message` and `start_time`.
- Updated `_calculate_duration` to handle `start_time` as an integer.
- Ensured `start_time` is reset using `perf_counter()` after each event handling.
- Adjusted tool and chain event handler calls to accommodate the new return type.
* Add start_time and duration checks to agent event handlers in tests
- Updated test cases for `handle_on_chain_start`, `handle_on_chain_end`, `handle_on_tool_start`, `handle_on_tool_end`, `handle_on_tool_error`, and `handle_on_chain_stream` to include `start_time` as a return value.
- Added assertions to verify that `start_time` is a float and `duration` is an integer where applicable.
* [autofix.ci] apply automated fixes
* update colors and spacing of time
* [autofix.ci] apply automated fixes
* Refactor DurationDisplay component to display duration in seconds
* Rename case from "message" to "add_message" in buildUtils.ts switch statement
* Add event registration for message removal in EventManager
* Add category handling for message events in Component class
* Add custom exception handling for agent message processing
* Handle exceptions in agent event processing with message deletion and event notification
* Add new LLM options and refactor AgentComponent for dynamic provider handling
- Introduced new language model options: Anthropic, Groq, and NVIDIA.
- Refactored `AgentComponent` to utilize `MODEL_PROVIDERS_DICT` for dynamic provider handling.
- Simplified input management by removing hardcoded provider inputs and using a dictionary-based approach.
- Enhanced `update_build_config` to support flexible provider configurations and custom options.
* Refactor buildUtils.ts and add message removal handling
* Update Source model to allow None values for id, display_name, and source fields
* Refactor event handler functions to return tuple of Message and float
* Refactor `ChatOutput` class to use `MessageInput` instead of `MessageTextInput` for `input_value` across starter projects.
* Add test for updating component outputs with dynamic code input
* feat: add ToolModeMixin to manage tool mode state
* feat: add parameterName to mutateTemplate for enhanced template mutation
* feat: add tool mode functionality to node toolbar
Implement a toggle for tool mode, allowing users to easily switch functionalities within the node toolbar. This enhancement improves user interaction by providing a dedicated mode for tool-related tasks.
* feat: integrate ToolModeMixin into MessageTextInput for enhanced functionality
* Update parameterId to "tool_mode" in nodeToolbarComponent
* feat: implement tool mode output handling in run_and_validate_update_outputs
* feat: add conditional rendering for tool mode button based on template fields
* fix: enhance null checks for tool mode button visibility and output validation
* feat: add isToolMode property to NodeInputFieldComponentType for enhanced functionality
* feat: add isToolMode prop to NodeInputField for conditional styling
* feat: implement sorting logic for tool mode fields in GenericNode component
* feat: add isToolMode prop to NodeOutputField for conditional styling
* feat: pass isToolMode prop to NodeOutputField for conditional styling
* feat: update disabled logic in NodeInputField to include isToolMode
* Add default placeholder to getPlaceholder function and constants file
* feat: Enable dynamic placeholders in input components
Add support for customizable placeholder text across various input components to enhance usability and improve user experience.
* feat: Add optional placeholder prop to InputProps type
* feat: Add placeholder prop to InputGlobalComponent and CustomParameterComponent
* feat: Set dynamic placeholder for NodeInputField based on tool mode
* feat: Update NodeOutputField styling for tool mode and pass isToolMode prop
* feat: Add isToolMode prop to OutputComponent for dynamic styling
* feat: Add TOOL_OUTPUT_DISPLAY_NAME constant for toolset display
* feat: Update tool output display name to use TOOL_OUTPUT_DISPLAY_NAME constant
* feat: Conditionally render Freeze Path button based on tool mode
* Add support for asynchronous output methods and tool mode validation in component tools
* feat: Validate required inputs for tool mode before executing output methods
* Refactor: Rename method to indicate private access in custom_component
- Changed `get_function_entrypoint_return_type` to `_get_function_entrypoint_return_type` in `custom_component.py` to reflect its intended private usage.
- Updated references to the renamed method in `utils.py` and `directory_reader.py` to maintain consistency.
* feat: Implement tool output mapping based on tool mode presence in inputs
* Refactor tests to use private method _get_function_entrypoint_return_type
* feat: Enable tool mode for input_value in LCAgentComponent
* Add test for updating component outputs with dynamic code input
* feat: add tool mode functionality to node toolbar
Implement a toggle for tool mode, allowing users to easily switch functionalities within the node toolbar. This enhancement improves user interaction by providing a dedicated mode for tool-related tasks.
* feat: add conditional rendering for tool mode button based on template fields
* feat: add isToolMode prop to NodeInputField for conditional styling
* feat: Set dynamic placeholder for NodeInputField based on tool mode
* feat: Add TOOL_OUTPUT_DISPLAY_NAME constant for toolset display
* feat: Conditionally render Freeze Path button based on tool mode
* Add tool mode support to LCAgentComponent
- Introduced new input fields: `agent_name`, `agent_description`, and `add_tools_to_description` to support tool mode.
- Implemented methods `get_tool_name`, `get_tool_description`, `_build_tools_description`, and `to_toolkit` for handling tool-related functionalities.
- Enhanced `MessageTextInput` with additional information for better user guidance.
- Updated agent message sender name to use `agent_name` if available.
* Fix return statement placement in event handling logic
* Add tool mode enhancements and error handling in component_tool
- Introduce optional parameters `tool_name`, `tool_description`, and `callbacks` to `get_tools` method.
- Implement error handling for tool creation with `handle_tool_error` and `callbacks`.
- Ensure single tool validation when `tool_name` or `tool_description` is provided.
- Add support for `BaseModel` result serialization using `model_dump`.
* Refactor agent response method and update output configuration
* Remove unused 'input_value' field from tool_calling.py configuration
* Refactor source property assignment to use _build_source method
* Enhance callable input check and add callbacks to toolkit conversion
* Add unit tests for message update functionality in backend
- Implement tests for updating single and multiple messages.
- Add tests for handling nonexistent messages during updates.
- Include tests for updating messages with timestamps, content blocks, and nested properties.
- Ensure proper serialization and storage of message properties.
* Add field serializer for 'output' using jsonable_encoder in content_types.py
* Add tool mode fields and refactor message response in starter projects
- Introduced new fields `add_tools_to_description`, `agent_description`, and `agent_name` for tool mode configuration in JSON starter projects.
- Refactored `message_response` method to utilize `_build_source` for constructing message source properties.
- Updated method references from `get_response` to `message_response` for consistency.
- Adjusted input field descriptions and added missing metadata attributes.
* Implement no-op send_message function and patching decorator for component tools
* Refactor output handling in component tool to support Message and Data types
* Simplify exception handling by removing redundant exception re-raise
* Enhance tool assignment logic to preserve existing name and description if not provided
* feat: Enhance agent name and description handling
Refactor the agent component to dynamically include tool names in the default agent name and description. This improves clarity for users by providing more context about the agent's capabilities and ensures consistent representation of tools in the interface.
* refactor: Update agent description and name info to include default values and dynamic tool integration
* Add custom encoders for serialization and refactor schema modules
- Introduce `CUSTOM_ENCODERS` in `encoders.py` to handle serialization of `Callable` and `datetime` objects.
- Refactor `BaseContent` to use `model_serializer` for model serialization with custom encoders.
- Remove redundant `encode_callable` function and `CUSTOM_ENCODERS` definition from `artifact.py`.
- Update imports and clean up unused imports in schema modules.
* Remove 'agent_name' field and update 'get_tool_name' method in agent.py
* Enhance `serialize_model` method with `wrap` mode and improved error handling
* Add 'tool_mode' attribute to frontend node class
* Add unit tests for ContentBlock initialization and content handling
* Add unit tests for content types serialization and creation
* Refactor tool mode initialization logic in NodeToolbarComponent
* Add tool mode functionality to node toolbar and flow store
* Add updateNodeInternals call for tool_mode case in nodeToolbarComponent
* Add condition to hide handle in tool mode in NodeInputField component
* Add shortcut for activating Tool Mode and integrate into node toolbar
* Add tool_mode parameter to MessageTextInput and update attributes mapping
* Remove 'agent_name' field from Agent Flow configuration file
* Update agent message to use display_name instead of agent_name
* Add validation for required tools in agent execution and component setup
* Make 'tools' field required in AgentComponent configuration
* test: add unit tests for run_and_validate_update_outputs functionality
Implement comprehensive tests for the `run_and_validate_update_outputs` method across various scenarios, including enabling/disabling tool mode, handling invalid output structures, and supporting custom update logic. Validate that outputs are correctly updated and ensure appropriate error handling for invalid cases.
* test: update component toolkit tests to use CalculatorToolComponent
* Enhance input schema creation logic for tool mode components
* Include input expression in error responses for calculator tool
* Enhance `visit_Attribute` to check for required inputs in `tree_visitor.py`
* fix: add checks for graph attribute before accessing session and flow IDs in Component methods
* fix: set default value to None for id field in PlaygroundEvent model
* fix: remove unused add_toolkit_output flag from FeatureFlags model
* Refactor JSON configurations to remove unnecessary required inputs across starter projects
* Add tool mode validation and improve error handling
- Updated import statement for ContentBlock to fix import path.
- Modified `send_message_noop` to require a `Message` parameter and added type ignore for method assignment.
- Enhanced error message in tool mode validation to handle `None` input names.
- Changed return type of `send_error_message` to `Message` for consistency.
- Provided default value for `get_tool_name` to handle missing display names.
* Add pytest fixture to test_component_message_sending test
---------
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
|
||
|
|
f96f2eaf8a |
ref: Add ALL ruff rules for tests (#4183)
Add ALL ruff rules for tests |
||
|
|
45c8f98692 |
ref: Auto-fix ruff rules in tests (#4154) | ||
|
|
047077cee4 |
ref: Remove autouse from pytest client fixture (#4158)
Remove autouse from pytest client fixture |
||
|
|
eb53f66641 |
ref: Use pathlib in tests (#4159)
Use pathlib in tests |
||
|
|
2adda780c9 |
tests: update env.py and conftest so tests use unique databases (#3654)
* Refactor Alembic environment script to simplify database connection logic and remove unused imports * Refactor test client fixture to use TemporaryDirectory and UUID for database path * Add `reload_engine` method to reinitialize the database engine * Add cleanup steps to test fixtures to ensure proper resource management - Added cleanup steps to various pytest fixtures to ensure temporary directories, database entries, and other resources are properly cleaned up after tests. - Modified fixtures to use `yield` for better resource management. - Ensured database connections are closed and tables are dropped after tests. - Improved temporary directory handling with context managers. * Add unit test to verify return type of list_flows method in custom component * Refactor tests in `test_custom_component.py` to remove unused imports and fixtures, and update existing fixtures for consistency. * Add debug checks for user existence in `test_user_waiting_for_approval` test * Fix import order and add flow_id validation in transaction handling - Corrected the import order in `utils.py`. - Added validation for `flow_id` in the transaction handling logic to ensure it is set correctly. * Add function to delete transactions by flow ID in CRUD module * Add cleanup for transactions and vertex builds in test teardown - Introduced `_delete_transactions_and_vertex_builds` function to remove transactions and vertex builds associated with a user. - Updated `user` fixture to call the new cleanup function before deleting the user. * Refactor flow_id assignment logic in `utils.py` to improve readability and correctness * [autofix.ci] apply automated fixes * Refactor test to use pytest's tmp_path fixture for temporary directory creation * Convert `test_user_waiting_for_approval` to an async test function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> |
||
|
|
270f609fe7 |
refactor: enhance tool creation logic and add FeatureFlags (#3662)
* Add `required_inputs` field to `Output` model in `base.py` * Refactor ComponentTool to ComponentToolkit and enhance tool creation logic - Replaced `ComponentTool` with `ComponentToolkit` to better encapsulate component-related tools. - Introduced `build_description` and `_build_output_function` helper functions for dynamic tool creation. - Updated tool initialization to handle multiple outputs and required inputs using `StructuredTool`. - Improved schema creation for tool arguments based on component inputs. * Refactor `to_tool` method to `to_toolkit` to use `ComponentToolkit` instead of `ComponentTool` * Refactor `ComponentTool` to `ComponentToolkit` in unit tests - Updated import statements to reflect the new `ComponentToolkit` class. - Modified test logic to use `ComponentToolkit` for retrieving tools. - Adjusted assertions to match the new structure and output format. - Ensured compatibility with `Message` schema for output validation. * Refactor `test_component_to_tool` to validate `ComponentToolkit` and tool properties * Refactor `build_description` to include input types in the output format * Add method to set required inputs for outputs based on method analysis - Introduced `_set_output_required_inputs` method to determine and set required inputs for each output by analyzing the method's source code. - Added necessary imports (`ast` and `dedent`) to support the new functionality. * Update test to assert full tool description in test_component_to_tool.py * Add unit tests for verifying required inputs of various components - Added tests to ensure that required inputs for outputs are present in the inputs of `ChatInput`, `ChatOutput`, `SequentialTaskComponent`, `ToolCallingAgentComponent`, and `OpenAIModelComponent`. - Included helper functions to check if required inputs are in inputs and to assert that all outputs have different required inputs. * Add RequiredInputsVisitor to identify required inputs in AST nodes - Introduced RequiredInputsVisitor class to traverse AST nodes and collect required inputs. - The visitor checks for 'self' attributes matching the provided inputs and adds them to the required_inputs set. * Refactor required inputs extraction using `RequiredInputsVisitor` * Add feature flags configuration for toolkit output in settings * Add toolkit output handling based on feature flag in custom component utils * Add method to append 'component_as_tool' output in custom component * Add unit test for toolkit output feature flag in custom component * Add utility functions for lazy loading and instantiating input types in langflow - Introduced `get_InputTypesMap` for lazy loading of `InputTypesMap`. - Added `instantiate_input` function to create instances of input types dynamically. - Included type checking and error handling for invalid input types. * Refactor input instantiation logic and update imports - Removed `instantiate_input` function from `inputs.py` and moved it to `utils.py`. - Updated imports in `base.py` to reflect the new location of `instantiate_input`. - Added missing import for `Callable` in `base.py`. * Refactor import statement to use `instantiate_input` from `langflow.inputs.utils` in test_inputs.py * Add TOOL_OUTPUT_NAME constant to tools module * Add type checking and TOOL_OUTPUT_NAME filter in ComponentToolkit - Introduced `TYPE_CHECKING` for type hints to avoid circular imports. - Added `TOOL_OUTPUT_NAME` constant to filter specific outputs in `ComponentToolkit`. - Updated type annotations to use forward references. * Refactor component toolkit import to avoid circular dependency and use constant for tool output name * Refactor `ComponentToolkit` class to remove inheritance from `BaseToolkit` and add an initializer for `component` * Add unit test for ComponentToolkit in test_component_to_tool - Added `test_component_to_tool_has_no_component_as_tool` to verify that `ComponentToolkit` correctly initializes with a `ChatInput` component and returns the expected tools. * Refactor toolkit output handling to `custom_component` module * fix: mypy errors union-attr and arg-type * Add 'OTHER' field type to schema in langflow/io/schema.py * Add tool name formatting to ComponentToolkit to ensure valid characters * Refactor toolkit output handling and add type hint for `to_toolkit` method * Add `is_interface_component` attribute to vertex types and update import order * Add tests for ToolCallingAgentComponent and ChatOutput with API key handling - Updated `test_component_tool` to reflect new description format. - Added `test_component_tool_with_api_key` to test `ToolCallingAgentComponent` with `ChatOutput` and OpenAI API key. - Enabled `add_toolkit_output` feature flag for testing. * Refactor `_find_matching_output_method` to accept `input_name` parameter for more precise input-output matching * Replace ValueError with warning in build_description function * use chat_output component directly in set * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 3/3) * Refactor: Reorder method calls in `__init__` for logical consistency Moved `set_class_code` method call to ensure output types and required inputs are set before class code initialization. * Update _format_tool_name to allow '.' in tool names * Refactor `_format_tool_name` to remove non-alphanumeric characters * Update test assertions for component tool name and output mapping * Handle case where 'required_inputs' is empty in 'component_tool.py' * Refactor import statements for better readability in `base.py` * [autofix.ci] apply automated fixes * Add noqa comment to suppress import warning and re-add Any import in base.py --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> |
||
|
|
bee466e52b |
refactor: update ATTR_FUNC_MAPPING and tools to match other tools (#3709)
* Refactor YfinanceToolComponent to inherit from LCToolComponent and remove unused outputs * Refactor `PythonREPLToolComponent` to use new input configuration and update method signatures * Add functions to handle dict values in ATTR_FUNC_MAPPING for '_outputs_maps' and '_inputs' * Handle '_outputs_maps' argument in frontend node creation * Add unit test for custom component subclassing from LCToolComponent * Add input and output handling to PythonREPLToolComponent - Introduced `input_value` to `inputs` for capturing user input. - Added `outputs` to define the output structure, including `api_run_model` and `tool` for backward compatibility. - Implemented `run_model` method to execute the tool and return results as `Data`. * Add input and output handling to YfinanceToolComponent - Introduced `MessageTextInput` for user queries. - Added `Output` definitions for `api_run_model` and `tool` methods. - Implemented `run_model` method to execute tool with user input. * Add input and output definitions to YfinanceTool for better data handling * Update error message to use display_name instead of vertex_type in edge validation * Add unit test for YfinanceToolComponent template output validation * Refactor tool components to include 'Data' output and update input types - Added 'Data' output type to 'Agent Flow', 'Sequential Agent', and 'Complex Agent' starter projects. - Updated input types to use 'MessageTextInput' and 'MultiselectInput' for better input handling. - Refactored code to align with new input and output structures, ensuring backward compatibility. * Add unit test for PythonREPLToolComponent template validation * test: disblable test --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com> |
||
|
|
3643d962b9 |
fix: deepcopy component output to avoid overriding previous outputs (#3698)
* Fixes copy of component outputs * Fix issue with copying outputs in custom components - Update loop to iterate over `_outputs.values()` instead of `outputs` to ensure correct attribute setting. * Refactor output handling in custom component to use dictionary values - Updated methods to iterate over `_outputs.values()` instead of `outputs`. - Ensured consistent access to output values across various methods. - Fixed potential issues with output value resetting and state model building. * Fix incorrect attribute reference in set_output_value method * Add missing import for CustomComponent in test_custom_component.py * Refactor `test_read_flow` to generate unique flow names for each test run * Refactor: Rename `_outputs` to `_outputs_map` in custom component - Updated all references of `_outputs` to `_outputs_map` in `component.py` to improve clarity and consistency. - Adjusted related methods and attributes in `base.py` to align with the new naming convention. * Fix output handling in custom component - Moved `_reset_all_output_values` call to ensure outputs are reset after initialization. - Updated attribute access to use `_outputs_map` instead of `_outputs` for consistency. --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> |
||
|
|
aaaf6f3784 |
refactor: replace get_actions call with get_tools in Composio Component (#3684)
* refactor: update deprecated call to get_actions * Update composio-langchain dependency to version 0.5.13 in pyproject.toml * Downgrade `composio-langchain` dependency to version `0.5.9` in `pyproject.toml` * Add missing import for CustomComponent in test_custom_component.py |
||
|
|
48fb846a4d |
refactor: change typing annotations in tests folder (#3594)
* refactor(log_router.py): change variable type annotation from List to list for better consistency refactor(utils.py): change variable type annotation from Dict to dict for better consistency refactor(base.py): change variable type annotation from Optional to Union for better clarity refactor(callback.py): change variable type annotation from Dict to dict for better consistency refactor(chat.py): change variable type annotation from Optional to Union for better clarity refactor(endpoints.py): change variable type annotation from Optional to Union for better clarity refactor(flows.py): change variable type annotation from List to list for better consistency refactor(api): update response_model annotations to use lowercase list for consistency and improve readability refactor(store.py): update type annotations for query parameters in get_components endpoint to improve code readability and maintainability feat(store.py): add support for type hinting Union and list types in query parameters for better data validation and documentation * run make format * refactor(input_mixin.py): update typing annotations for variables to use union types for better clarity and compatibility with Python 3.10 refactor(inputs.py): update typing annotations for variables to use union types and import necessary modules for compatibility with Python 3.10 * refactor(base.py): remove unnecessary imports and update typing for fields in Input and Output classes feat(base.py): add support for specifying field types more explicitly in Input and Output classes feat(frontend_node/base.py): enhance typing and field definitions in FrontendNode class feat(frontend_node/custom_components.py): improve typing and field definitions in CustomComponentFrontendNode and ComponentFrontendNode classes feat(template/base.py): update typing for fields in Template class and remove unnecessary imports * refactor(inputs): remove unnecessary Optional import from typing in input_mixin.py and inputs.py files to improve code readability and maintainability * refactor(schema.py): change 'Type' to 'type' for consistency in type annotations refactor(schema.py): change 'list' to 'List' and 'Literal' to 'literal' for correct type hinting in create_input_schema function * refactor(utils.py): change typing annotations from List and Union to list and type to follow PEP 585 standards refactor(test_schema.py): change typing annotations from List and List to list and list to follow PEP 585 standards refactor(test_graph.py): change typing annotations from Type and Union to type and Vertex | None to follow PEP 585 standards refactor(test_io_schema.py): change typing annotations from List and List to list and list to follow PEP 585 standards refactor(test_custom_component.py): update file reading method to remove unnecessary "r" mode refactor(test_helper_components.py): update file reading method to remove unnecessary "r" mode refactor(test_kubernetes_secrets.py): update b64encode method argument to bytes type refactor(test_template.py): change typing annotations from Optional, List, and Dict to list, dict, and None to follow PEP 585 standards * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> |
||
|
|
919073a0db |
feat: import Graph without position information (#3203)
* refactor: Add utility functions for getting handle IDs in CustomNodes - Added `getRightHandleId` function to generate the right handle ID for source handles. - Added `getLeftHandleId` function to generate the left handle ID for target handles. - These functions improve code readability and maintainability by encapsulating the logic for generating handle IDs. * refactor: Add type for escaped handle IDs in edges to improve type safety in reactflowUtils * feat: Add function to escape handle IDs in edges, enhancing edge management in reactflowUtils * feat: Add function to check edges without escaped handle IDs, improving edge validation in reactflowUtils * feat: Enhance edge processing in reactflowUtils to handle edges without escaped handle IDs more effectively * feat: Add layoutUtils module for handling node layout using elkjs * feat: update processDataFromFlow to add layout to nodes if needed * Refactor import paths to use 'initialize' module in 'base.py' * feat: Add method to set class source code and integrate it with frontend node input field * refactor: Update sourceHandle dataType to use custom component class name * fix: Raise error for unknown vertex types instead of returning default Vertex class * refactor: Remove redundant call to _import_vertex_types() in VertexTypesDict initialization * refactor: Simplify add_code_field by removing unnecessary field_config parameter from function signature * feat: Add elkjs dependency to package.json and package-lock.json for enhanced functionality in the frontend * refactor: Update fields type in Template class to use InputTypes for improved type safety * refactor: Reorganize imports in __init__.py for better structure and consistency across the inputs module * refactor: Clean up imports in types.py for better organization and consistency in the graph vertex module * refactor: Change vertex type annotations to strings for better compatibility and consistency in the graph module methods * refactor: Update component instantiation to include _code parameter and fix input type annotations for improved type handling * refactor: Remove unused CustomComponent import from __init__.py for cleaner module structure and improved organization * refactor: Modify custom_component instantiation to include _code argument for enhanced functionality and clarity in CodeParser class * refactor: Update CustomComponent import in __init__.py for improved module structure and organization * refactor: Update launch.json to include correct path for backend source files * refactor: Update dependencies in poetry.lock to latest versions and resolve merge conflicts in backend files * refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name * refactor: Correct flow_id reference in MemoryComponent to improve clarity and consistency in memory handling * refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py * refactor: Add loading module to __init__.py for improved organization of interface package * refactor: Clean up imports in base.py and enforce edge validation in Graph class for improved maintainability and error handling * refactor: Remove edge component additions in test_base.py to streamline graph tests and emphasize error handling for unprepared graphs * refactor: Mark @clack/prompts is-unicode-supported as extraneous in package-lock.json for better dependency management * refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name * refactor: Fix edge existence check in Graph class to use correct variable, ensuring accurate validation of graph structure * refactor: Add test for graph with edge and improve graph preparation logic * refactor: Set default node type to "genericNode" in getLayoutedNodes for consistent layout structure * create consts for node widht and height * refactor: Catch and log errors when processing flow data in flowsManagerStore and reactflowUtils * [autofix.ci] apply automated fixes * fix: Validate custom components for source and target vertices in Graph edges * test: Add fixture for client and raise TypeError for invalid class parsing in CodeParser tests * test: Add unit test for listing flows as Flow objects in custom component with client * test: Update assertions for memory chatbot component types in unit tests * test: Refactor assertions to use updated component names in vector store RAG unit tests * fix: Change error handling to return default Vertex for unknown node types in graph class * [autofix.ci] apply automated fixes * test: Add pytest fixture for CustomComponent in unit tests to enhance test structure and readability * chore: Update component names in vector store RAG unit tests * test: Refactor imports and make flow name generation unique in database unit tests * chore: Remove unused upload and flow management functions from flowsManagerStore for cleaner codebase * chore: Await processDataFromFlow in useAddFlow hook * chore: Correct NODE_HEIGHT calculation to use NODE_WIDTH constant for consistency in constants file * chore: Remove extraneous flag for is-unicode-supported in package-lock.json for cleaner dependency management --------- Co-authored-by: anovazzi1 <otavio2204@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> |
||
|
|
f706b05438 |
refactor: enhance CustomComponent class and updates tests (#3201)
* fix: update CustomComponent to use properties for user_id and flow_id Refactored user_id and flow_id in CustomComponent to use properties for better encapsulation and code clarity * refactor: update CustomComponent initialization and remove unused imports Refactored the CustomComponent class to streamline initialization and removed unnecessary import for BaseCallbackHandler * refactor: update build_custom_component_template to use cc_instance for field order to improve consistency and clarity * refactor: update user_id parameter in FlowToolComponent to use self.user_id for consistency * refactor: remove unused _tree attribute and clean up imports in CustomComponent for better code clarity * refactor: rename CustomComponent to Component for consistency in directory_reader.py import and usage * refactor: enhance timestamp handling in _timestamp_to_str for better validation and error reporting in message.py * refactor: preserve async get_file_content_dicts method for backwards compatibility in message.py * refactor: update function_entrypoint_name to _function_entrypoint_name for consistency in test_custom_component.py * feat: add client fixture for improved test structure in test_data_components.py * feat: add unit tests for PromptComponent including template processing and custom fields in test_prompt_component.py * feat: add dev dependencies for improved testing and development tools in pyproject.toml |
||
|
|
e0afe90410 |
refactor: update code references to use _code instead of code (#3113) | ||
|
|
0122a50a35 |
refactor: move tests folder structure and update pytest commands (#2785)
* refactor: move tests folder to src/backend * chore(Makefile): update pytest commands to run tests from the correct directory paths for unit and integration tests * refactor: update file path in test_custom_component.py The file path in the test_custom_component.py file has been updated to use the correct relative path to the component_multiple_outputs.py file. This change ensures that the test code can access the correct file and improves the reliability of the test. |
Renamed from tests/unit/test_custom_component.py (Browse further)