Simplified Run Flow
Executes a specified flow by ID.
Executes a specified flow by ID with input customization, performance enhancements through caching, and optional data streaming.
Parameters:
db
(Session): Database session for executing queries.flow_id_or_name
(str): ID or endpoint name of the flow to run.input_request
(SimplifiedAPIRequest): Request object containing input values, types, output selection, tweaks, and session ID.api_key_user
(User): User object derived from the provided API key, used for authentication.session_service
(SessionService): Service for managing flow sessions, essential for session reuse and caching.
SimplifiedAPIRequest:
input_value
(Optional[str], default=""): Input value to pass to the flow.input_type
(Optional[Literal["chat", "text", "any"]], default="chat"): Type of the input value, determining how the input is interpreted.output_type
(Optional[Literal["chat", "text", "any", "debug"]], default="chat"): Desired type of output, affecting which components' outputs are included in the response. If set to "debug", all outputs are returned.output_component
(Optional[str], default=None): Specific component output to retrieve. If provided, only the output of the specified component is returned. This overrides theoutput_type
parameter.tweaks
(Optional[Tweaks], default=None): Adjustments to the flow's behavior, allowing for custom execution parameters.session_id
(Optional[str], default=None): An identifier for reusing session data, aiding in performance for subsequent requests.
Tweaks
A dictionary of tweaks to customize the flow execution.
The tweaks can be used to modify the flow's parameters and components.
Tweaks can be overridden by the input values.
You can use Component's id
or Display Name as key to tweak a specific component
(e.g., {"Component Name": {"parameter_name": "value"}}
).
You can also use the parameter name as key to tweak all components with that parameter
(e.g., {"parameter_name": "value"}
).
Returns:
- A
RunResponse
object containing the execution results, including selected (or all, based onoutput_type
) outputs of the flow and the session ID, facilitating result retrieval and further interactions in a session context.
Raises:
- HTTPException: 404 if the specified flow ID curl -X 'POST'
Example:
curl -X 'POST' 'http://<your_server>/run/{flow_id}' -H 'accept: application/json' -H 'Content-Type: application/json' -H 'x-api-key: YOU_API_KEY' -H '
-d '{
"input_value": "Sample input",
"input_type": "chat",
"output_type": "chat",
"tweaks": {},
}'
This endpoint provides a powerful interface for executing flows with enhanced flexibility and efficiency, supporting a wide range of applications by allowing for dynamic input and output configuration along with performance optimizations through session management and caching.
Path Parameters |
---|
flow_id_or_name Flow Id Or Name — REQUIRED |
Query Parameters |
---|
stream Stream |
user_id User Id |
Request Body |
---|
undefined |
Responses | |||||
---|---|---|---|---|---|
200 Successful Response
| |||||
422 Validation Error
|