Refining Action Inputs, Outputs & Schemas

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:

  • 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, postprocessors, or schema processors.

These can be applied at two levels:

  1. Tool-level: Affects all actions within a specific tool.
  2. Action-level: Tailored processing for individual actions.

Here’s how you can implement these processors:

1

Define the Preprocessor, Postprocessor, and Schema Processor Functions

2

Use them while creating the toolset

Ensure that your schema processing, preprocessing, and postprocessing functions are efficient and don’t introduce significant latency.