diff --git a/docs/introduction/foundations/components/actions/processing.mdx b/docs/introduction/foundations/components/actions/processing.mdx index 1b25ba3be6c..f7c3dc58e67 100644 --- a/docs/introduction/foundations/components/actions/processing.mdx +++ b/docs/introduction/foundations/components/actions/processing.mdx @@ -1,18 +1,19 @@ --- -title: "🛠️ Enhancing Action Inputs & Outputs" +title: "🛠️ Enhancing Action Inputs, Outputs & Schemas" sidebarTitle: "Processing Actions" icon: "wand-magic-sparkles" -description: "Master the art of preprocessing and postprocessing actions for optimal results." +description: "Master the art of preprocessing, postprocessing, and schema processing for optimal results." --- -## Refining Action Inputs & Outputs +## Refining Action Inputs, Outputs & Schemas -In many scenarios, the raw inputs or outputs of actions may benefit from additional processing. This refinement step can significantly improve the quality and usability of your data. Here are two key use cases: +In many scenarios, the raw inputs, outputs, or schemas of actions may benefit from additional processing. This refinement step can significantly improve the quality and usability of your data. Here are three key use cases: -- **Postprocessing**: Streamline large action responses by filtering or formatting the data before it reaches the Language Model (LLM). - **Preprocessing**: Generate or modify inputs dynamically at runtime, handling scenarios that may be challenging for the LLM to produce directly. +- **Postprocessing**: Streamline large action responses by filtering or formatting the data before it reaches the Language Model (LLM). +- **Schema Processing**: Modify the request schema to include additional fields or alter existing ones. -Composio empowers you with the ability to define **custom Python functions** as preprocessors or postprocessors. +Composio empowers you with the ability to define **custom Python functions** as preprocessors, postprocessors, or schema processors. These can be applied at two levels: @@ -21,9 +22,13 @@ These can be applied at two levels: Here's how you can implement these processors: - + -```python Define the Preprocessor or Postprocessor Functions +```python Define the Preprocessor, Postprocessor, and Schema Processor Functions +def tool_schema_processor(schema): + # Modify schema as needed + return modified_schema + def tool_preprocessor(input_data): # Modify input_data as needed return modified_input_data @@ -32,6 +37,10 @@ def tool_postprocessor(output_data): # Process output_data as needed return processed_output_data +def action_schema_processor(schema): + # Modify schema as needed + return modified_schema + def action_preprocessor(input_data): # Modify input_data as needed return modified_input_data @@ -44,10 +53,14 @@ def action_postprocessor(output_data): -```python Set the pre and post processors while creating the toolset -# while defining the toolset, you can define the pre and post processors +```python Set the schema, pre, and post processors while creating the toolset +# While defining the toolset, you can define the schema, pre, and post processors composio_toolset = ComposioToolSet( processors={ + "schema": { + App.GITHUB: tool_schema_processor, + Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER: action_schema_processor, + }, "pre": { App.GITHUB: tool_preprocessor, Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER: action_preprocessor, @@ -65,7 +78,6 @@ tools = composio_toolset.get_tools(apps=[App.GITHUB]) - - Ensure that your preprocessing and postprocessing functions are efficient and don't introduce significant latency. + Ensure that your schema processing, preprocessing, and postprocessing functions are efficient and don't introduce significant latency.