aixplain.factories.team_agent_factory.inspector_factory
Factory module for creating and configuring inspector agents.
This module provides functionality for creating inspector agents that can validate and monitor team agent operations. Inspectors can be created from existing models or using automatic configurations.
WARNING: This feature is currently in private beta.
Example:
Create an inspector from a model with adaptive policy::
inspector = InspectorFactory.create_from_model( name="my_inspector", model_id="my_model",
model_config=\{"prompt"
- "Check if the data is safe to use."}, policy=InspectorPolicy.ADAPTIVE, )
Notes:
Currently only supports GUARDRAILS and TEXT_GENERATION models as inspectors.
InspectorFactory Objects
class InspectorFactory()
Factory class for creating and configuring inspector agents.
This class provides methods for creating inspector agents either from existing models or using automatic configurations. Inspectors are used to validate and monitor team agent operations, providing feedback and enforcing policies.
create_from_model
@classmethod
def create_from_model(
cls,
name: Text,
model: Union[Text, Model],
model_config: Optional[Dict] = None,
policy: InspectorPolicy = InspectorPolicy.ADAPTIVE) -> Inspector
Create a new inspector agent from an onboarded model.
This method creates an inspector agent using an existing model that has been onboarded to the platform. The model must be of a supported function type (currently GUARDRAILS or TEXT_GENERATION).
Arguments:
name
Text - Name of the inspector agent.model
Union[Text, Model] - Either a Model instance or model ID string to use for the inspector.model_config
Optional[Dict], optional - Configuration parameters for the inspector model (e.g., prompts, thresholds). Defaults to None.policy
InspectorPolicy, optional - Action to take upon negative feedback:- WARN: Log warning but continue execution
- ABORT: Stop execution on negative feedback
- ADAPTIVE: Dynamically decide based on context Defaults to InspectorPolicy.ADAPTIVE.
Returns:
Inspector
- Created and configured inspector agent.
Raises:
ValueError
- If:- Model ID is invalid
- Model is not onboarded
- Model function is not supported
Exception
- If model retrieval fails
create_auto
@classmethod
def create_auto(
cls,
auto: InspectorAuto,
name: Optional[Text] = None,
policy: InspectorPolicy = InspectorPolicy.ADAPTIVE) -> Inspector
Create a new inspector agent using automatic configuration.
This method creates an inspector agent using a pre-configured InspectorAuto instance, which provides automatic inspection capabilities without requiring a specific model.
Arguments:
auto
InspectorAuto - Pre-configured automatic inspector instance.name
Optional[Text], optional - Name for the inspector. If not provided, uses the name from the auto configuration. Defaults to None.policy
InspectorPolicy, optional - Action to take upon negative feedback:- WARN: Log warning but continue execution
- ABORT: Stop execution on negative feedback
- ADAPTIVE: Dynamically decide based on context Defaults to InspectorPolicy.ADAPTIVE.
Returns:
Inspector
- Created and configured inspector agent using automatic inspection capabilities.