Commit graph

14,220 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
c5495c4aac
fix: Remove 'refresh_button' from DropdownInput in AgentComponent configuration (#4471)
* Remove 'refresh_button' from DropdownInput in AgentComponent configuration

* Add 'Current Date' tool option to AgentComponent inputs and update response method

* Disable refresh button in Agent Flow starter project configuration
2024-11-08 17:43:50 +00:00
Lucas Oliveira
a09652ca5f
fix: refactor loading of main page, use new Sidebar in main page, fix small UI bugs (#4451)
* Tighten space between main page sidebar buttons

* Fixed skeleton size

* Added playground button back

* Updated no components and flows state

* Update default icon to Workflow

* Fixed size of list cards

* Removed browse store

* Removed playground button

* Removed black background from empty folder state

* Update empty state color

* Fix color of empty state

* fix text not selectable

* updated border color

* added shadow only on hover

* Remove JSON from Download JSON

* Fixed colors and weight of tabs on home page

* Fixed padding on list and grid components

* Update icons that take long to load

* Fixed icon and bg color for home tiles

* Removed unused code

* removed placeholder data for skeleton to not appear on first load

* Make onSuccess refetch the queries so that the loading waits for it

* Removed unused divs on foldersidebarnav

* Refactor sidebar buttons to use new shadcn sidebar

* Created skeletons for folder, grid and list

* Added new sidebar size

* Use new sidebar button on header and implemented animation

* Changed icon to getIcon

* Added sidebar provider and fixed loading states of the main page

* Removed folder buttons on emptyPage

* Fixed foldername to appear immediatly, and fixed loading states for the folders

* Removed unused state from folders store

* Removed unused states from folders store type

* Added new icon

* fixed modals component to not show a trash icon

* Changed icons to load immediatly

* Added empty folder condition to not display header info

* Added conditions to show loading state until everything loads

* Created empty folder state

* Changed empty page to correct colors

* Added skeletons while flows of the folder are loading

* Removed shadow from text

* Fixed font chivo taking long time to load

* Fix adding new folder not redirecting

* [autofix.ci] apply automated fixes

* Fixed colors and paddings on list and grid components

* Re added tooltips to upload and create folders

* fix input for name editing

* Fix tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-08 17:33:52 +00:00
Lucas Oliveira
6761df6110
fix: update nav bar UI, changed user menu to use shadcn dropdown, fix responsivity issues (#4454)
* Updated saved color

* Removed selection from header /

* hide text from 1200px

* Updated github star style

* Fixed hover state on account menu

* Fix misalignment of store

* Changed user menu to use dropdown menu from shadcn

* Fixed notification dot

* Change mobile responsivity

* Fixed flow settings name

* Implement opening the sidebar when hitting /

* Fixed code opening when hitting space on sidebar

* Fixed errors with tests
2024-11-08 17:20:36 +00:00
Eric Hare
a4863bbe57
fix: pdf parsing, pass as str instead of posix path (#4448)
* FIX: PyMuPDF for parsing, pass as str instead of posix path

* Switch back to pypdf due to licensing

* Allow specification of the number of threads

* [autofix.ci] apply automated fixes

* Update file.py

* Switch StrInput to IntInput

*  (Document QA.json, Vector Store RAG.json): Update FileComponent class to include IntInput for concurrency_multithreading to control the number of workers for parallel processing. This enhancement allows for better control and optimization of processing tasks.

* ⬆️ (pyproject.toml): upgrade langchain-core dependency from version 0.3.10 to version 0.3.12 to ensure compatibility and leverage new features

* ⬆️ (pyproject.toml): update langchain-core dependency to allow versions greater than or equal to 0.3.12 for compatibility reasons

---------

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>
2024-11-08 16:55:06 +00:00
Gabriel Luiz Freitas Almeida
98274633db
fix: remove use of ImagePromptTemplate in image handling and adds image utils (#4467)
* remove poetry.lock

* fix: update langchain-core dependency version to 0.3.15

* feat: add functions to convert images to base64 and create data URLs

* refactor: simplify image URL handling by replacing ImagePromptTemplate with create_data_url function

* Fix image URL structure in data schema to use nested dictionary format

* Add unit tests for Data schema message conversion with text and images

* test: add unit tests for image utility functions to validate base64 conversion and data URL creation

* Refactor image URL generation to use `create_data_url` utility function instead of `ImagePromptTemplate`

* Add unit tests for message handling and image processing in schema module

- Introduce fixtures for temporary cache directory and sample image creation.
- Add tests for message creation from human and AI text.
- Implement tests for messages with single and multiple images.
- Include tests for invalid image paths and messages without sender.
- Add message serialization and conversion tests.
- Ensure cleanup of cache directory after tests.

* Use platformdirs to determine cache directory paths in test_schema_message.py
2024-11-08 08:24:19 -08:00
Gabriel Luiz Freitas Almeida
7114cc4799
ci: Add temporary database setup for performance tests (#4469)
Add temporary database setup for performance tests and assertions for database URL
2024-11-08 14:41:01 +00:00
Mendon Kissling
1138869d0f
Docs: backend only mode (#4405)
* initial-cleanup-and-test

* better-flow

* config

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* more-why-clarity

* cleanup

* code-review-and-tech-review

---------

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>
2024-11-08 14:00:43 +00:00
Ítalo Johnny
19301b1cce
ci: stop backend unit tests on first failure (#4466)
ci: stop backend unit tests on first failure
2024-11-08 13:23:25 +00:00
Edwin Jose
0f6098aa28
feat: add tool mode to components, Added current date tool to agent (#4439)
* 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

* new components with tool mode

* updated the tests and also updated api request to accept the  data from tool calling agent

* added current date as tool

* [autofix.ci] apply automated fixes

* 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.

* remove tool_mode from Chrome

* Update agent.py

adding current date tool to agent

* 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

* fix linkComponent test

* Skip flaky test in stop-building.spec.ts

* new components with tool mode

* updated the tests and also updated api request to accept the  data from tool calling agent

* added current date as tool

* [autofix.ci] apply automated fixes

* remove tool_mode from Chrome

* Update agent.py

adding current date tool to agent

* Ensure tools is a list before appending CurrentDateComponent in AgentComponent

* Add pytest fixture 'client' to component test functions

* Use 'client' fixture in test_component_streaming_message

* Skip flaky test in stop-building.spec and add tool_mode to MessageTextInput

* [autofix.ci] apply automated fixes

* Update agent.py

updates to solve the error in Date component as tool.

* Add `updateComponentCode` function to enhance code update flexibility

- Introduced `updateComponentCode` function to handle import and input updates more flexibly using regex patterns.
- Updated unit test to utilize the new function for modifying component code, including adding `LinkInput` configuration.

* Add tool mode to components and introduce current date tool option

- Added `tool_mode` attribute to `MessageTextInput` in `CalculatorToolComponent` and `URLComponent` to enable tool mode functionality.
- Introduced `add_current_date_tool` option in `AgentComponent` to allow agents to include a tool that returns the current date.
- Updated `AgentComponent` to handle the addition of the current date tool as a `StructuredTool`.

* update test code generation

* remove meta key to ctrl

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: phact <estevezsebastian@gmail.com>
2024-11-08 09:53:32 -03:00
Edwin Jose
0bf7dda009
fix: component-set-handle-list-tools (#4465)
update component.py

I added a StructuredTool to define the set function in the component. This change resolved an error that occurred when the list of tools was set by the component. In the future, we may need to add tests to manage unexpected situations in the component's set function.

I also updated the pytest.
2024-11-08 10:11:13 +00:00
Gabriel Luiz Freitas Almeida
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>
2024-11-08 02:31:04 +00:00
Edwin Jose
1434786cf6
fix: adding atlassian-python-api to support confluence components (#4430)
adding atlassian-python-api to support confluence components
2024-11-07 21:18:17 +00:00
Jordan Frazier
3a1c0301cd
buid: reduce number of layers in runtime env for langflow-ep build (#4457)
Reduce number of layers in runtime env
2024-11-07 12:33:46 -08:00
Jordan Frazier
18d08413ce
build: add curl to ep image (#4456)
Add curl to ep image
2024-11-07 12:29:26 -08:00
Edwin Jose
01698214ab
fix: removed Pytest that uses Add Tool Output (#4437)
* removed Pytest that uses Add Tool Output

No longer required

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-07 20:15:03 +00:00
Cristhian Zanforlin Lousa
f9ae9f27f3
feat: Enhance sidebar components (#4452)
* 📝 (pageLayout/index.tsx): update beta icon text from "BETA" to "Beta" for consistency and readability

*  (custom-parameter.tsx): add support for flex view in custom parameter title to improve UI flexibility and readability

*  (NodeInputField/index.tsx): refactor NodeInputField component to pass isFlexView prop to getCustomParameterTitle function for improved customization and flexibility

* 📝 (NodeStatus/index.tsx): update text from "BETA" to "Beta" for consistency and readability

*  (flowSidebarComponent/index.tsx): Add new components and features to the Flow Sidebar Component to enhance user experience and functionality. Update the structure and logic of the component to improve search functionality, error handling, and component filtering.

*  (emptySearchComponent): add a new component NoResultsMessage to display a message when no components are found in the search result. The component includes options to clear the search, filter, and try a different query.

*  (featureTogglesComponent/index.tsx): add a new component FeatureToggles to manage feature toggles for Beta and Legacy features in the sidebar of the FlowPage.

* 📝 (sidebarDraggableComponent): Update CSS classes for better styling and spacing
💡 (sidebarDraggableComponent): Improve readability by changing font weight of text elements
💡 (sidebarDraggableComponent): Update text content to be more consistent and capitalized

*  (index.tsx): Add a new component SidebarFooterButtons to display buttons in the sidebar footer for adding custom components and navigating to the store page.

*  (index.tsx): add a new component SidebarItemsList to render a list of items in the sidebar with tooltips and draggable functionality

*  (apply-beta-filter.ts): add a new helper function applyBetaFilter to filter out beta items from the given data based on a specific condition

*  (apply-edge-filter.ts): introduce a new helper function applyEdgeFilter to filter data based on edge filters for a better user experience.

*  (apply-legacy-filter.ts): introduce a new helper function applyLegacyFilter to filter out legacy data from APIDataType object.

*  (combined-results.ts): add a new helper function combinedResultsFn to combine Fuse.js search results with API data for each category

*  (filtered-data.ts): introduce a new helper function filteredDataFn to merge and return filtered data from different sources for a given category in the FlowPage component.

*  (normalize-string.ts): introduce a new helper function normalizeString to convert a string to lowercase, remove underscores, and spaces for better string normalization.

*  (ParentDisclosureComponent): Change "BETA" to "Beta" for consistency in text formatting
 (search-on-metadata.ts, traditional-search-metadata.ts): Add helper functions for searching in metadata and traditional search metadata to improve search functionality in the flow sidebar component.
2024-11-07 15:45:26 -03:00
Cristhian Zanforlin Lousa
e63cace20a
fix: Improve Connection Line Styling and Cleanup Unused Code in FlowPage Components (#4449)
 (ConnectionLineComponent/index.tsx): introduce accentColor variable to dynamically set stroke and accent color based on handleDragging color
♻️ (PageComponent/index.tsx): refactor code to remove unused variables zoomIn, zoomOut, fitView, and zoom to improve code readability and maintainability

Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
2024-11-07 12:53:40 -03:00
Ítalo Johnny
a45f0ac872
docs: replace --timeout with --worker-timeout (#4447) 2024-11-07 11:47:58 -03:00
Ítalo Johnny
e6a1bd3ec2
feat: add cli option to display version (#4444) 2024-11-07 14:07:21 +00:00
Cristhian Zanforlin Lousa
ada5f17d13
fix: Add Helper for Field Processing & Update Code Validation Logic (#4429)
* 📝 (GenericNode/index.tsx): Add import statement for cloneDeep from lodash library
📝 (GenericNode/index.tsx): Add import statement for processNodeAdvancedFields helper function
📝 (GenericNode/index.tsx): Add edges variable to store edges state using useFlowStore hook
📝 (GenericNode/index.tsx): Modify onSuccess callback to process and update node data with advanced fields using processNodeAdvancedFields helper function

*  (process-node-advanced-fields.ts): add a new function to process advanced fields of a node based on edges in a graph for better customization and control.

* ♻️ (GenericNode/index.tsx): Remove unused import of cloneDeep from lodash to clean up the code and improve maintainability.

* 🔧 (process-node-advanced-fields.ts): rename variable edgesWithNode to relevantEdges for clarity and consistency
🐛 (process-node-advanced-fields.ts): fix condition to check relevantEdges length instead of edgesWithNode length for correct logic

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
2024-11-07 13:41:23 +00:00
Gabriel Luiz Freitas Almeida
311bf00b8e
fix: update error message structure in ChatMessage component (#4445)
* refactor: Update error message structure in ChatMessage component for clarity

* update error message format and content

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
2024-11-07 10:26:24 -03:00
dependabot[bot]
ab5103b9d1
build(deps): bump http-proxy-middleware from 2.0.6 to 2.0.7 in /docs (#4244)
Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/chimurai/http-proxy-middleware/releases)
- [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.7/CHANGELOG.md)
- [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: http-proxy-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-07 12:46:42 +00:00
dependabot[bot]
e047e13918
build(deps): bump elliptic from 6.5.5 to 6.6.0 in /docs (#4325)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.5 to 6.6.0.
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.5...v6.6.0)

---
updated-dependencies:
- dependency-name: elliptic
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-07 12:34:13 +00:00
Mendon Kissling
4cc9912f1b
Feat: Add Docusaurus redirect capability (#4435)
* added-package-tested-and-works

* starter-redirect
2024-11-07 11:59:40 +00:00
anovazzi1
472b5fbda5
fix: resolve issue with adding global variable when input is connected (#4289)
* fix: prevent add global variable when inpiut is connected

* [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>
2024-11-07 11:47:07 +00:00
Gabriel Luiz Freitas Almeida
a1cddbc335
feat: add ContentBlock streaming visualization (#4370)
* Refactor cardComponent and storeCardComponent to comment out playground buttons

* Refactor message model to replace 'meta_data' with 'properties' and update related schema and components

* Add new schema for content types with Pydantic models

* Add ContentBlock schema with support for multiple content types

* Refactor: Import ContentBlock from langflow.schema.content_block instead of defining locally

* Add SendMessageFunctionType protocol to log schema for message handling

* Refactor chat message model to replace 'meta_data' with 'properties' and update related components

* Add ContentBlock import and enhance send_message method in component.py

- Import ContentBlock from langflow.schema.content_block.
- Replace 'meta_data' with 'properties' in message construction.
- Update send_message method to handle optional Message and text parameters.

* Add async on_chain_start method to callback for logging chain start events

* Refactor add_messagetables function to replace 'meta_data' with 'properties' in message processing

* Fix typo in 'traceback' property name in ErrorDetails interface

* Add condition to check chat history length before rendering chat lock

* Refactor error content structure and enhance message event handling

* Add `update_messages` function to handle message updates in memory module

* Add check for 'id' attribute in stored_message for message validation

* Add new content types and TypeAlias for schema in content_types.py

* Add custom serialization for UUID and BaseModel types in data schema

* Refactor `ContentType` to use `ContentTypes` union and update `content` field in `ContentBlock` model

* Update model to use specific types for properties and content_blocks fields

* Change return type of 'serialize_params' method to string

* Add sender fields and properties handling to PlaygroundEvent and create_message function

* Refactor chat message component to use 'properties' instead of 'meta_data' for chat attributes

* Refactor message handling to improve error categorization and session management

* Enhance ContentBlock initialization to update model fields with defaults

* Add new content types and update ContentBlock interface in chat types

- Introduced BaseContent interface and various content types: ErrorContent, TextContent, MediaContent, JSONContent, CodeContent, ToolStartContent, ToolEndContent, and ToolErrorContent.
- Created a union type ContentType for all content types.
- Updated ContentBlock interface to include new content structure and additional fields.

* Refactor error handling in chat messages to use `ErrorContent` type

* Add ErrorMessage class for handling error-specific messages in schema

* Add type annotations for cache and logs in custom_component.py

* Refactor error handling in custom component to use `send_error` method

* Add customizable properties for chat components

- Introduced new properties: `background_color`, `chat_icon`, and `text_color` to chat components across various starter projects.
- These properties allow for customization of the chat message appearance, including icon and text styling.
- Updated the `ChatInput` and `ChatOutput` components to handle these new properties and include them in the message response.

* Add 'category' field to MessageEvent and update create_message function

* Remove unused message handling methods from ChatComponent

* Refactor message event handling in chat module

* Add 'category' field to Message creation and pass 'id_' in _send_message_event

* Add 'category' field with Literal type to Message schema and default handling in chat IO

* Refactor message event handling in chat module

* Refactor buttonSendWrapper component to add data-testid attribute

* Refactor ChatComponent to replace 'store_message' with 'send_message' method

* refactor: streamline message handling in Component

Update message processing to utilize new methods for improved clarity and efficiency. Enhance event data management to ensure accuracy and consistency in message updates.

* feat: Update input handling and output storage for chat components

Enhance chat input and output components to improve message handling, including updates to storage and display properties. This facilitates better user experience and message management in various agent projects.

* Ensure 'id' field is set in message data dictionary if not present

* refactor: Simplify property retrieval from source component in ChatComponent

* refactor: Replace property retrieval logic with a dedicated method in ChatOutput

* Refactor `TokenEvent` class and add `timestamp` field with default factory

* refactor: Simplify message processing by removing unused parameters in async handling

* Refactor message text update logic in messagesStore

* Refactor border styling in ChatInput component

* refactor: Consolidate properties handling in PlaygroundEvent and create_message function

* refactor: Update timestamp formatting to include timezone information across multiple models

* refactor: Add StreamingError exception for better error handling in streaming components

* refactor: Add source_display_name attribute to Properties model for enhanced data representation

* refactor: Enhance ChatComponent to return source display name and update properties handling in ChatOutput

* refactor: Improve error handling in Component class and enhance create_error function with timestamp support

* feat: enhance ChatOutput component for improved message handling

Update the message_response method to include source display name and improve message storage functionality across various project templates. This enhances clarity and ensures consistent behavior of chat components.

* feat: add delete_message function to remove messages by ID from the monitor service

* Add error handling for message streaming and implement message deletion on failure

* feat: Enhance message streaming and event handling

Improve the streaming process to send message events only for non-streaming messages and ensure the initial message is sent correctly when processing chunks, enhancing the overall message handling flow.

* improve UI

* Refactor buttonSendWrapper component to add data-testid attribute and update tests

* fix edited tag

* add tooltip to add button

* fix bug after merge

* update examples

* updateinput without chat

* fix some frontend tests

* fix test

* update test

* Update fileUploadComponent.spec.ts to fix test and update input without chat

* refactor event creation functions and enhance ErrorEvent structure

* refactor ErrorMessage to use Source for sender and component details

* refactor Properties to use Source model for source details and add validation

* refactor ChatMessage component for improved readability and structure

* refactor ChatMessageType to use PropertiesType for improved structure and clarity

* Add Source ID to message properties and update exception handling

- Updated `message_response` method to include `source_id` in the `Properties` object for better traceability.
- Modified `StreamingError` to use `Source` object instead of `component_name` for more detailed error context.
- Adjusted `get_properties_from_source_component` to return `source_id` along with other properties.

* Add 'Source' property to error handling in custom_component module

- Introduced 'Source' property to enhance error message details.
- Updated error handling to include 'source' instead of 'display_name'.
- Modified exception raising to use 'source' for better traceability.

* Enhance event ID generation with event type prefix in `send_event` method

* Refactor ChatOutput class to use Properties and Source schemas for message properties

* update style in tailwind and add fallback for nullable values

* fix playground test

* Update message handling in Component class to send modified message copy on first chunk

* Add flow_id and session_id to ErrorEvent creation function

* 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

---------

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>
2024-11-06 23:35:35 +00:00
Mike Fortman
f41bc6ef5f
refactor: Design updates to API Dialog and Code Block for uplift sweep (#4431)
* api dialog sweep

* update code blocks

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-06 22:49:30 +00:00
Mike Fortman
63435689d4
refactor: Design updates to Playground from uplift sweep (#4428)
* design sweep changes

* [autofix.ci] apply automated fixes

* update truncate fade

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-06 15:58:41 -06:00
Jordan Frazier
91ccf1f458
ref: simplify docker build workflow (#4294) 2024-11-06 12:38:05 -08:00
Cristhian Zanforlin Lousa
9394fe1ca6
feat: Enhance UI Consistency and Refactor Color Naming Conventions for Improved UX (#4424)
* 📝 (tailwind.config.mjs): refactor color classes from "inner-" to "accent-" for better clarity and consistency in naming conventions

* 🔧 (GenericNode/index.tsx): Remove unused imports and constants to clean up the code and improve maintainability
♻️ (GenericNode/index.tsx): Refactor GenericNode component by removing unnecessary code related to BuildStatus and BorderBeam to simplify the component and improve readability

* 🔧 (handleRenderComponent/index.tsx): rename innerColorName and innerForegroundColorName variables to accentColorName and accentForegroundColorName for better clarity and consistency
🔧 (handleRenderComponent/index.tsx): update CSS variables to use accent prefix instead of inner for better naming convention and readability
🔧 (handleRenderComponent/index.tsx): pass accentColorName and accentForegroundColorName props to HandleTooltipComponent for improved customization and styling

* 📝 (HandleTooltipComponent/index.tsx): Refactor HandleTooltipComponent to use Badge component for tooltip styling and add support for custom accent colors and foreground colors based on left alignment. Update styles and data-testid attributes accordingly.

* 📝 (NodeStatus/index.tsx): update border and text color classes for better visual consistency and clarity

* 🐛 (get-class-from-build-status.ts): fix incorrect condition to return class based on build status, now correctly returns class for BUILDING status

*  (nodeToolbarComponent/index.tsx): Add zoom functionality to NodeToolbarComponent using ReactFlow's store selector to dynamically adjust scale based on zoom level.

* 📝 (applies.css): add a new CSS class .toolbar-wrapper to style the toolbar with flex layout, spacing, border, background color, padding, and shadow for better visual appearance

* 📝 (index.css): Update accent color variables to improve consistency and readability in the stylesheet.

* [autofix.ci] apply automated fixes

* Update src/frontend/src/style/applies.css

Co-authored-by: Mike Fortman <michael.fortman@datastax.com>

* Update src/frontend/src/CustomNodes/GenericNode/components/HandleTooltipComponent/index.tsx

Co-authored-by: Mike Fortman <michael.fortman@datastax.com>

*  (NodeStatus/index.tsx): Improve border styling for selected and unselected nodes for better visual consistency
🔧 (applies.css): Remove unnecessary border width specification in various CSS classes to simplify styling and improve maintainability

* 🔧 (PageComponent/index.tsx): Update innerColor variable to accentColor for better clarity and consistency in styling
🔧 (sidebarFilterComponent/index.tsx): Update backgroundColor style to use accent color instead of inner color for better visual consistency
🔧 (nodeToolbarComponent/index.tsx): Add relative positioning to the buttons in the NodeToolbarComponent for better alignment on the page

*  (nodeToolbarComponent/index.tsx): Add styleClasses property to ShadTooltip component to apply custom styling for positioning
♻️ (applies.css): Refactor CSS classes to use shorthand notation for height and width properties, and update class names for better readability and maintainability

* 🔧 (nodeToolbarComponent/index.tsx): update button height class to improve consistency and readability

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
2024-11-06 19:42:48 +00:00
anovazzi1
0c049deee3
fix: Refactor API key header and remove streaming (#4427)
refactor: Update API key header in get-js-api-code.tsx and remove streaming
2024-11-06 18:48:07 +00:00
Cristhian Zanforlin Lousa
73df2182de
fix: General Fixes and Improvements from v1.0.19.2 Fixes Branch (#4411)
* fix: update assistants client import (#4150)

* remove unnecessary patch

* remove unnecessary patch

* compatible release operator

* chore: add opensearch-py dependency (#4134)

Add opensearch-py dependency to pyproject.toml

* patch version

* lock

* lock some packages to speed up pip install

* langflow-base version

* fix: fix retrieverTool component (#4201)

♻️ (RetrieverTool.py): refactor build method signature to accept additional keyword arguments for future extensibility

* Fixed save modal not exiting

* fix: object has no attribute 'set_event_manager' (#4200)

* 🐛 (base.py): fix AttributeError by checking if custom_component has set_event_manager method before calling it

* 📝 (base.py): Import Component from langflow.custom to improve code readability and maintainability
♻️ (base.py): Refactor code to use isinstance() method for checking if custom_component is an instance of Component

* Refactor: Eliminate Global Variables for Improved Code Maintainability_fix_release (#4208)

Refactor: Eliminate Global Variables for Improved Code Maintainability

- Replaced global variables with local variables or class attributes.
- Enhanced code readability and reduced potential side effects.

* fix: Update example (#4204)

update example

* fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defin… (#4203)

fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defined and fixes build method

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>

* fix: unexpected keyword argument 'code' -> SQLExecutor and SQLDatabase (#4230)

🔧 (SQLDatabase.py): update build method signature to accept additional keyword arguments for future extensibility
🔧 (SQLExecutor.py): update method signature to accept additional keyword arguments for future extensibility

* lock httptools to 0.6.4

* Move ChatInput import to within flow_component fixture in conftest.py

* Simplify error message formatting in test cases for data components

* Add readme to dockerfile

* build: dockerfile with entrypoint (#4062)

Adds a dockerfile with an entrypoint for use with Datastax Langflow

* fixes the leading v for checking out commits correctly

* fixes on more version checkout for docker build

*  (authContext.tsx): Add functionality to fetch global variables on authentication
🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated
 (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency

* [autofix.ci] apply automated fixes

* revert changes to workflows

* upgrade lockfile

* update pyproject versions

* update lockfile again

* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99

* ⬆️ (pyproject.toml): downgrade version from 0.0.99 to 0.0.97 to align with project requirements and dependencies.

* ⬆️ (pyproject.toml): downgrade langflow-base dependency version from 0.0.99 to 0.0.97 to resolve compatibility issues

* ⬆️ (uv.lock): downgrade langchain-core package version from 0.3.15 to 0.3.12 to resolve compatibility issues with dependencies

* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99 to utilize the latest features and improvements

---------

Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: João <38133825+joaoguilhermeS@users.noreply.github.com>
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: Jordan Frazier <122494242+jordanrfrazier@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-06 17:31:36 +00:00
Edwin Jose
ae7d037fe1
feat: Add Multi-Model Provider Support to Agent Component (#4416)
* Add Multi-Model Provider Support to Agent Component

- Integrated model provider constants from `model_input_constants.py` into the Agent component to support multiple LLM providers
- Added dynamic field management for different model providers (OpenAI, Azure, Groq, Anthropic, NVIDIA)
- Implemented a dropdown for model provider selection with automatic input field updates

* sorted list

* Update agent.py

making custom separate from sort

* chore: remove unit test

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-11-06 11:15:22 -05:00
Mike Fortman
16924958da
refactor: Design tweaks canvas actions and templates based on uplift feedback (#4418)
* uplift sweep for canvas actions and templates

* [autofix.ci] apply automated fixes

* test fix

* test fix 2

* one more fix

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
2024-11-06 09:52:21 -06:00
Lucas Oliveira
de7b23ea93
fix: improve notes functionality, update theme colors definition and resolve ui and ux small bugs (#4414)
* Fixed background blur overlay color on dialogs

* Try to fix f5 error

* Fix text color of notes

* Fix bg color of nodenode to first one available if not existent

* Removed unused imports

* Added new node colors

* Updated color of placeholder note node

* Fixed notes to appear as soon as when the add button is clicked

* Added transparent option to notes

* Fixed editor design

* Fix design of notes editor

* Update text color on the note node description

* Added canvas dot variable

* Added size and gap definition to background dots

* Updated emerald colors and badge

* used correct badges on tableAutoCellRender

* Used correct colors on the component global variable badge

* Fix color on light mode

* Fixed emerald color on the status of component

* Applied static pink to active icons on navs

* Make sidebar narrower

* Updated size of /

* Fixed Beta and Legacy badges

* Fixed position of chevron

* Fixed node name input

* Updated clear search button

* Updated color for grid dots

* Updated sidebar filter color

* Added chat input check

* Fixed sorting of flow sidebar component

* Fix canvas color

* Updated sticky notes test

* Fixed tests

* Fixed test
2024-11-06 14:54:43 +00:00
Gabriel Luiz Freitas Almeida
e5969b2f18
ci: Update Codspeed workflow to exclude api_key_required tests and enable parallel execution (#4412)
fix: update codspeed workflow to exclude api_key_required tests and run in parallel
2024-11-06 12:52:29 +00:00
Irshad Ahamed M B
ed692530fb
fix: correct issue with handling float32 (#4312)
* Update pinecone.py

Error building Component Pinecone: Invalid type for variable '0'. Required value type is float and passed type was float64 at ['values'][0]

Fixed the issue by forcing float32

* [autofix.ci] apply automated fixes

* Linit Recommendation Handled

Linit Recommendation Handled

* [autofix.ci] apply automated fixes

* refactor: Simplify Float32Embeddings implementation

Streamline the Float32Embeddings class by removing unnecessary parent linkage and consolidating the embedding logic, ensuring consistent float32 output for embeddings.

* refactor: Re-arranging the code.

Co-Authored-By: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* [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>
2024-11-06 11:32:03 +00:00
Christophe Bornet
e853a13d57
feat: Add AsyncSession support for non-blocking db operations (#4408)
* Add AsyncSession support for non-blocking db operations

* Use sqlalchemy extras
2024-11-06 03:21:53 -08:00
Eric Hare
07d8f2e04b
feat: Error handling and multi-file support in File Component (#4353)
* FEAT: Error handling and multi-file support in File Component

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Update file.py

* [autofix.ci] apply automated fixes

* Add support for multithreading in zips

* [autofix.ci] apply automated fixes

* Add PDF processing support

* [autofix.ci] apply automated fixes

* Update file.py

* [autofix.ci] apply automated fixes

* Update file.py

* [autofix.ci] apply automated fixes

* Update file.py

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-05 23:10:41 +00:00
Deon Sanchez
f17934b7b8
fix: Fix Home Page Issues post Uplift (#4362)
* fixes spotted by otavio

* Refactor folder export logic and fix folder name in download link

* Refactor getTemplateStyle to handle partial matches in flowData.name

* Refactor folder export logic and add file drop functionality

* spelling

* Re enable/fix drag and drop behaviors

* [autofix.ci] apply automated fixes

* folder upload fix

---------

Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-05 22:47:54 +00:00
Cristhian Zanforlin Lousa
a0184369bb
feat: Change Beta Tag and UI Enhancements for Node Components (#4417)
📝 (NodeName/index.tsx): Add beta prop to NodeName component for better handling of beta features
📝 (NodeStatus/index.tsx): Import Badge component and add beta badge for beta nodes
📝 (GenericNode/index.tsx): Import Badge component and add beta badge for beta nodes
📝 (nodeToolbarComponent/index.tsx): Add border styling to nodeToolbarComponent for better visual separation
📝 (index.css): Update accent-pink and accent-pink-foreground colors for better contrast
2024-11-05 21:50:54 +00:00
Eric Hare
9d4d41c5f5
fix: Handle BYO Embeddings (#4387) (#4410)
bugfix: Handle BYO Embeddings (#4387)
2024-11-05 19:32:25 +00:00
Cristhian Zanforlin Lousa
d261077e9f
fix: center add and remove icon on button when is a inputList (#4407)
 (index.tsx): update Button component className to include additional styling for icon size and alignment

Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>
2024-11-05 17:32:42 +00:00
Cristhian Zanforlin Lousa
d9445ebb15
fix: server busy error even when the server is responding (#4403)
 (api.tsx): add utility store to manage health check timeout in the API interceptor
📝 (api.tsx): update comments in the code for better readability and understanding

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-11-05 17:20:27 +00:00
anovazzi1
01de9efef2
fix: Minor fixes and feature flag removal (#4409)
* minor fixes in playground

* remove feature flag

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-05 17:06:20 +00:00
Mike Fortman
f6616f5d31
feat: changes the ui and ux of the api dialog to improve usability (#4338)
* init

* dialog uplift

* color updates

* remove weird active state

* [autofix.ci] apply automated fixes

* match code highlighter themes through out

* add tweaks tooltip

* icon resize

* [autofix.ci] apply automated fixes

* dark vs light style + merge fix

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>
2024-11-05 16:31:15 +00:00
Lucas Oliveira
91b650fd03
fix: sidebar animations, colors and minor design fixes (#4379) 2024-11-05 16:15:04 +00:00
Gabriel Luiz Freitas Almeida
7b5ba8e8f5
Revert "fix: Optimize Setting of Output Required Inputs" (#4404)
Revert "fix: Optimize Setting of Output Required Inputs (#4389)"

This reverts commit 7cc497aa52.
2024-11-05 15:55:48 +00:00
Cristhian Zanforlin Lousa
1443af2e42
tests: add decision flow test (#4384)
*  (Vector Store.spec.ts): Update test to skip if required environment variables are not set and improve test flow for Vector Store RAG test.

*  (Vector Store.spec.ts): Update variable name from 'control' to 'Control' for better clarity and consistency
📝 (decisionFlow.spec.ts): Refactor test case to skip if OPENAI_API_KEY is not provided and improve code readability and maintainability by restructuring and commenting out unnecessary code blocks

* 📝 (Vector Store.spec.ts): Comment out unnecessary test.skip blocks and unused code to improve code readability and maintainability.

* refactor: update test to click on "New Flow" instead of "New Project"

*  (store-shard-2.spec.ts): Refactor test to use a reusable function for clicking elements and waiting for visibility to improve code readability and maintainability
🔧 (deleteFlows.spec.ts): Refactor test to use separate functions for waiting for and interacting with elements to improve code readability and maintainability
2024-11-05 11:55:22 -03:00
Cristhian Zanforlin Lousa
84d07d9ec3
feat: add minimize and expand functionality for UI nodes (#4388)
*  (frontend): improve UI by dynamically showing/hiding elements based on showNode state
🔧 (frontend): update node internals when toggling showNode state
📝 (frontend): add test for minimizing and expanding components

* 🔧 (handleRenderComponent/index.tsx): refactor getHandleClasses function to improve code readability and maintainability
🔧 (handleRenderComponent/index.tsx): refactor handleClick function to improve code readability and maintainability

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-11-05 13:02:10 +00:00