-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add endpoint to allow passing files when running flows #5588
base: main
Are you sure you want to change the base?
Conversation
c793976
to
5d686e0
Compare
CodSpeed Performance ReportMerging #5588 will degrade performances by 17.39%Comparing Summary
Benchmarks breakdown
|
0100041
to
a100e8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome, left a couple small NITs but i love this.
bd85b3e
to
c754e06
Compare
- Introduced an `update` method in the `Tweaks` class to allow merging of a dictionary into the `root` attribute. - This enhancement improves the functionality of the `Tweaks` class by enabling dynamic updates to its internal state.
- Introduced a new POST endpoint `/run/upload/{flow_id_or_name}` to execute flows with support for file uploads and streaming responses. - Enhanced input handling to accept both JSON body and form data, allowing for flexible request formats. - Implemented file processing logic to validate and store uploaded files, integrating them into the flow execution context. - Added telemetry logging for flow execution metrics, improving monitoring and debugging capabilities. - Updated dependencies and imports to accommodate new functionality.
…ation - Added form data validation to the SimplifiedAPIRequest model, allowing for JSON string input and ensuring proper parsing. - Introduced a new model_config with JSON schema examples to guide API users on expected input formats. - Implemented an as_form method to facilitate the creation of model instances from form data, improving usability in web contexts. - Updated imports for better organization and clarity in the schemas.py file.
- Added a fixture for creating and cleaning up file flow components in tests. - Improved assertions in existing tests for version and config endpoints to provide clearer error messages. - Introduced new tests for successful file uploads, handling invalid filename formats, and uploading multiple files. - Enhanced tests for running flows with file uploads, ensuring robust validation of responses and session management. - Updated imports and organized test structure for better readability and maintainability.
…and update SimplifiedAPIRequest model - Removed JSON parsing for tweaks in the simplified_run_flow_with_upload function, directly using the input data. - Updated the SimplifiedAPIRequest model to handle tweaks as a JSON string, ensuring proper parsing during validation. - Enhanced unit tests to reflect changes in input handling, ensuring compatibility with the new structure.
…to use Tweaks class - Changed the initialization of `input_request.tweaks` from an empty dictionary to an instance of the `Tweaks` class when no tweaks are provided. - This change ensures that the tweaks are handled consistently as objects, improving the overall structure and functionality of the input handling in the flow execution context.
- Added a new file `run_utils.py` to handle flow execution, including support for file uploads and streaming responses. - Introduced `simple_run_flow` and `execute_flow` functions to manage flow execution and telemetry logging. - Implemented file processing logic to validate and store uploaded files, integrating them into the flow execution context. - Enhanced input validation with `validate_input_and_tweaks` to ensure proper handling of input values and tweaks. - Added asynchronous event consumption with `consume_and_yield` to track and yield events to clients. - Established a streaming response setup with `setup_streaming_response` to facilitate real-time updates during flow execution. - Improved error handling and telemetry logging for better monitoring of flow execution metrics.
- Integrated `execute_flow` and `setup_streaming_response` functions to enhance flow execution handling. - Removed extensive inline documentation and error handling from `simplified_run_flow`, delegating responsibilities to the new utility functions for improved readability and maintainability. - Updated the flow execution logic to support both streaming and non-streaming responses more efficiently. - Enhanced error handling by centralizing telemetry logging and exception management, ensuring consistent behavior across flow executions.
… empty dictionary - Changed the initialization of `input_request.tweaks` from an instance of the `Tweaks` class to an empty dictionary when no tweaks are provided. - This adjustment ensures that tweaks are handled as a standard dictionary, allowing for more flexible updates and integration with file processing logic.
…cumentation - Updated `simplified_run_flow` and `simplified_run_flow_with_upload` functions to include detailed docstrings for better clarity on parameters and return types. - Integrated `process_uploaded_files` to streamline file handling during flow execution. - Removed unused imports and improved overall code organization for better maintainability. - Enhanced error handling to provide more specific HTTP status codes for various failure scenarios. - Improved input request handling to support both JSON and form-data submissions, ensuring flexibility in API usage.
- Updated the validation logic in the SimplifiedAPIRequest model to ensure that the "tweaks" field is only parsed from a JSON string if it is provided as a string within a dictionary. - Enhanced error handling to provide more specific messages for JSON decoding errors related to the "tweaks" field, improving the clarity of error reporting.
- Enhanced error handling in the execute_flow function to provide more specific HTTP exceptions for different error types, including detailed messages for "not found" and "invalid chat input" scenarios. - Centralized telemetry logging for both successful and failed executions, ensuring consistent tracking of flow execution metrics. - Improved clarity of error messages returned to the client, aiding in debugging and user feedback.
- Refactored the error handling for "not found" scenarios to streamline the HTTPException raising process, improving clarity and consistency in error responses. - Enhanced the detail of the error message returned, aiding in debugging and user feedback.
…oint fixture for endpoint requests
…low_with_upload function
…_with_upload function
0ff6974
to
2753133
Compare
This pull request introduces several enhancements, including an
update
method in theTweaks
class for dynamic dictionary merging. A new POST endpoint/run/upload/{flow_id_or_name}
has been added to facilitate flow execution with file uploads, supporting both JSON and form data inputs. TheSimplifiedAPIRequest
model has been enhanced with form handling and validation, allowing for better usability. Additionally, comprehensive tests for file uploads and flow execution have been implemented to ensure robust functionality and error handling. Overall, these changes improve the flexibility and reliability of the API.