feat: add serve command to CLI#8862
Closed
ogabrielluiz wants to merge 75 commits into
Closed
Conversation
…ance node type checking
…ased on type strings
This commit introduces a new module for loading and validating Python scripts containing Langflow graph variables. It includes functions for dynamically importing scripts, validating graph instances, and extracting messages from results, enhancing the CLI's functionality.
… graph variables This commit introduces a new CLI command that allows users to analyze a Python script for a 'graph' variable, validate its type, and execute it to retrieve results. The command includes error handling for file existence, type checks, and provides informative output about the graph variable found in the script.
…cript outputs This commit introduces two new functions, `extract_text_from_result` and `extract_structured_result`, to enhance the processing of results from Langflow CLI scripts. These functions extract text content and structured data, respectively, while implementing error handling for improved robustness.
…mproved output formatting This commit updates the CLI command to execute Langflow graph scripts, adding options for verbose output and customizable result formats (json, text, message, or result). It improves error handling and captures logs during execution, providing a more informative user experience. The command now returns results in the specified format, enhancing usability in various environments.
…ully This commit modifies the `end_tracers` method in the TracingService class to return early instead of raising an error when no trace context is found. This change improves the robustness of the tracing functionality by preventing unnecessary exceptions in scenarios where tracing is not active.
This commit updates the TracingService class to log warnings instead of raising RuntimeErrors when the trace context is not found in various methods. This change enhances the robustness of the service by allowing it to handle missing contexts gracefully, preventing unnecessary exceptions and improving overall stability.
…h execution This commit enhances the existing CLI command to allow execution of Langflow graphs defined in JSON files, in addition to Python scripts. It improves error handling for file type validation and provides informative output during the analysis and execution process. The command now accommodates both .py and .json file formats, enhancing usability and flexibility for users.
This commit refactors the verbose output handling in the Langflow CLI command by introducing a dedicated `verbose_print` function. This change centralizes the logic for printing diagnostic messages, enhancing code readability and maintainability. Additionally, it ensures that all relevant error messages and execution details are consistently printed to stderr when verbose mode is enabled, improving the user experience during script analysis and execution.
This commit introduces a suite of tests for the Langflow CLI call command, enhancing coverage for various scenarios including valid and invalid Python scripts, JSON flows, and error handling for nonexistent or unsupported file types. New fixtures are added to create temporary scripts for testing, ensuring robust validation of output formats and error messages. The tests improve the reliability of the CLI command and provide a foundation for future enhancements.
This commit introduces detailed documentation for the new `langflow call` command, which allows users to execute Langflow graphs directly from the command line using Python scripts or JSON flow files. The documentation includes usage examples, argument descriptions, and available output formats, enhancing user understanding and accessibility of the CLI functionality.
…` to `execute` This commit updates the documentation for the Langflow CLI, changing references from the `langflow call` command to the new `langflow execute` command. The documentation now accurately describes the command's functionality, usage examples, and available options, ensuring clarity for users. Additionally, the command's arguments and output formats have been revised to align with the new naming convention.
…for execution This commit modifies the basic_prompting script to utilize the GPT-4.1-nano model for improved performance. Additionally, it introduces a new test fixture for executing the basic prompting graph, ensuring that the functionality works as expected. A test case is added to validate the execution of the graph, enhancing overall test coverage and reliability.
This commit introduces a new configuration option, `load_from_db`, to the OpenAIModelComponent. This enhancement allows the component to load the API key directly from the database, improving flexibility in managing sensitive credentials. The change aims to streamline the setup process for users while maintaining security best practices.
…pdate_params_with_load_from_db_fields This commit introduces a new function, `load_from_env_vars`, which allows parameters to be populated from environment variables when the database is unavailable. Additionally, it updates the `update_params_with_load_from_db_fields` function to utilize this new functionality, enhancing the robustness of parameter loading in scenarios where database access is not possible. The changes improve flexibility and error handling for missing environment variables.
This commit introduces comprehensive validation for JSON responses in the CLI tests related to the execute command. It replaces previous JSON parsing logic with a dedicated validation function, `validate_execute_command_json_response`, ensuring that responses adhere to expected structures and types. Additionally, new test cases are added to validate both successful and error responses, improving test coverage and robustness in handling various output scenarios.
* Fix the invalid folderId path * log fix
* test: add pyleak for task and event loop block detections * test: add pyleak for task and event loop block detections * ci: add env variables for verbose logging * chore: dummy sleep to shwocase error * chore: dummy sleep to showcase error * chore: remove dummy sleep
…meter render logic (#8493) * fix: enhance dropdown component with refresh button and clean up parameter render logic - Added a refresh button to the dropdown component, improving user interaction. - Refactored parameter render component to remove unnecessary wrapping around the render function. - Updated package-lock.json to remove extraneous dependencies. * [autofix.ci] apply automated fixes * refactor(OutputComponent): replace DropdownMenu with Popover and Command components - Updated OutputComponent to use Popover and Command components for improved UI interaction. - Refactored dropdown logic to enhance accessibility and user experience. - Added a reference for the button to manage focus visibility. * refactor: update Memory Chatbot configuration and remove unused RefreshParameterComponent - Changed display names and output methods in Memory Chatbot JSON configuration for clarity and consistency. - Introduced a new output method for retrieving messages as text. - Removed the RefreshParameterComponent and its references from the parameter render component to streamline the codebase. * refactor: update dropdown component layout for improved styling - Changed the layout classes in the dropdown component to enhance responsiveness and visual consistency. - Adjusted flex properties to ensure proper alignment and spacing based on the presence of filtered metadata. * refactor: streamline dropdown component structure and enhance button functionality - Removed redundant rendering functions for refresh and custom option dialogs, integrating them directly into the dropdown's main structure. - Improved layout and styling for better responsiveness and visual consistency. - Adjusted class names for better alignment and spacing, particularly in relation to filtered metadata. - Ensured the refresh button is consistently displayed based on dialog input conditions. * refactor: enhance dropdown component styling for better readability - Updated text size in dropdown options for improved visibility. - Increased padding in command items for better touch targets and visual consistency. * refactor: adjust dropdown component styling for improved usability - Reduced padding in the search input for a more compact design. - Updated text size in the search input for better readability. - Enhanced layout of filtered metadata display for clearer visibility. * refactor: enhance dropdown component rendering and styling - Added console log for filtered metadata to assist in debugging. - Adjusted class names in dropdown options for better responsiveness based on filtered metadata length. * feat: add data-testid attributes for refresh buttons and simplify memoization in ParameterRenderComponent - Added data-testid attributes to refresh buttons in Dropdown component for improved testability. - Removed unnecessary useMemo in ParameterRenderComponent to streamline rendering logic. - Introduced a new test for the refresh dropdown list functionality to ensure proper behavior. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
✨ (frontend): add CustomTermsLinks component to GeneralPage to display custom terms links in the settings page.
🐛 (code-tabs.tsx): fix button positioning by adjusting right margin to 4px instead of 2px
Changed run flow to not group outputs
…8815) * chore: add jest-junit dependency for improved test reporting - Updated package.json and package-lock.json to include jest-junit version 16.0.0, enhancing test reporting capabilities in the project. * chore: enhance Jest configuration for improved test coverage and CI reporting - Added coverage collection settings, including coverage thresholds and report formats. - Configured CI-specific options for Jest, including the use of jest-junit for test reporting and adjusted worker settings for better performance in CI environments. * chore: update frontend test command for CI mode to ensure proper environment variable usage - Modified the test command in the Makefile to set CI=true for accurate test execution in CI environments. * chore: enhance frontend CI workflow with test reporting and coverage uploads - Replaced the frontend dependency installation step with a command to run unit tests in CI mode. - Added steps to publish test results using junit report and to comment on pull requests with coverage summaries. - Implemented artifact upload for coverage reports to improve visibility and tracking of test coverage over time. * chore: add frontend dependency installation step to CI workflow - Introduced a step to install frontend dependencies using npm ci in the GitHub Actions workflow. - This enhancement ensures that all necessary packages are available before running frontend unit tests, improving the reliability of the CI process. * chore: update junit report action version in CI workflow - Upgraded the junit report action from v5 to v5.5.1 in the GitHub Actions workflow to leverage the latest features and improvements for test result reporting. * chore: add Jest unit test workflow for frontend - Introduced a new GitHub Actions workflow to run Jest unit tests for the frontend. - The workflow includes steps for checking out the repository, setting up the Node.js environment, running tests, publishing test results, adding coverage comments on pull requests, and uploading coverage reports. - This enhancement improves the CI process by ensuring comprehensive testing and reporting for frontend components. * chore: integrate Jest unit tests into CI workflow - Added a new job to the CI workflow to run frontend unit tests using Jest. - Updated the changes filter to include Jest test files, ensuring they are recognized during the CI process. - This enhancement improves the testing coverage and reliability of the frontend components.
Contributor
|
Build successful! ✅ |
Contributor
|
Build successful! ✅ |
- Added StreamRequest model to handle streaming input parameters, including session management and output customization. - Introduced consume_and_yield and run_flow_generator_for_serve functions to manage event streaming and client interaction. - Enhanced the serve_app with a new /stream endpoint for real-time flow execution, utilizing StreamingResponse for efficient data transfer. - Improved error handling during streaming setup and execution, ensuring robust client feedback in case of failures.
- Introduced comprehensive unit tests for the streaming capabilities of the multi-serve app, covering endpoint existence, basic functionality, request validation, and error handling. - Implemented tests for authentication requirements and flow existence checks, ensuring robust error responses. - Added validation tests for the StreamRequest model to confirm correct handling of input parameters. - Included tests for concurrent streaming requests to verify performance under load.
Contributor
|
Build successful! ✅ |
- Changed _lock initialization to lazy loading to avoid event loop binding issues. - Added a property method for lock to ensure proper initialization. - Introduced _reset_all_output_values method to reset output values for vertices before execution. - Updated start method to call prepare and reset output values. - Ensured _lock is reinitialized after unpickling the Graph instance.
- Implemented lazy initialization for asyncio.Lock to prevent event loop binding issues. - Added a static method for using threading.Lock in an async context. - Updated async methods to utilize the new lock property for thread safety. - Ensured proper reset of the lock during state restoration.
- Changed execute_graph_with_capture function to be asynchronous. - Updated the graph execution to use async iteration for capturing results. - Ensured compatibility with the existing graph execution flow.
…app to use async execution - Modified run_flow_generator_for_serve to await execute_graph_with_capture for asynchronous execution. - Implemented deepcopy of the graph in create_multi_serve_app to ensure thread safety during async calls. - Enhanced overall async handling in the serve application.
Contributor
|
Build successful! ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several updates to the Langflow project, including enhancements to the CLI, new functionality for executing Langflow graphs, and backend improvements. The most significant changes are the addition of the
executecommand for running Langflow graphs from the CLI, the introduction of MCP server support, and improvements to the backend for better type safety and functionality.CLI Enhancements:
executecommand to the CLI, allowing users to run Langflow graphs directly from Python scripts or JSON files. This includes support for input values, diagnostic output, and multiple output formats such as JSON and plain text. (src/backend/base/langflow/__main__.py,docs/docs/Configuration/configuration-cli.md, [1] [2]script_loadermodule with utilities for loading and validating Python scripts containing Langflow graph variables. This includes functionality for extracting structured results and handling errors gracefully. (src/backend/base/langflow/cli/script_loader.py, src/backend/base/langflow/cli/script_loader.pyR1-R237)Backend Improvements:
runfunction to ensure proper type handling for settings like host, port, and log level, providing default values when necessary. (src/backend/base/langflow/__main__.py, src/backend/base/langflow/main.pyL297-R306)custom_component_updateto ensure proper handling ofComponentinstances during parameter updates. (src/backend/base/langflow/api/v1/endpoints.py, src/backend/base/langflow/api/v1/endpoints.pyL720-R720)MCP Server Support:
src/backend/base/langflow/cli/mcp_server.py, src/backend/base/langflow/cli/mcp_server.pyR1-R53)CI Workflow Update:
test-frontend-unitjob to the CI workflow to run frontend unit tests separately, improving test coverage and modularity. (.github/workflows/ci.yml, .github/workflows/ci.ymlR175-R180)