django_agents.base
Base module for Django agents
Classes
Base class for asynchronous agents. |
|
Base class for every Django agent. |
|
Agent specialized in managing workflows. |
Exceptions
Base exception for agents |
|
Error raised when the agent execution fails |
|
Validation error for the execution context |
- exception django_agents.base.AgentValidationError[source]
Validation error for the execution context
- exception django_agents.base.AgentExecutionError[source]
Error raised when the agent execution fails
- class django_agents.base.BaseAgent[source]
Base class for every Django agent.
All agents must inherit from this class and implement the execute() method.
- abstractmethod execute(context: Dict[str, Any]) Dict[str, Any][source]
Executes the main agent logic
- Parameters:
context – Dictionary containing the execution context
- Returns:
Execution result as a dictionary
- Raises:
AgentExecutionError – If something goes wrong during execution
- validate_context(context: Dict[str, Any]) bool[source]
Validates the provided context
- Parameters:
context – Context to validate
- Returns:
True when the context is valid
- Raises:
AgentValidationError – If the context is not valid
- pre_execute(context: Dict[str, Any]) Dict[str, Any][source]
Hook executed before the main execution
- Parameters:
context – Execution context
- Returns:
Updated or original context
- post_execute(result: Dict[str, Any], context: Dict[str, Any]) Dict[str, Any][source]
Hook executed after the main execution
- Parameters:
result – Execution result
context – Execution context
- Returns:
Updated or original result
- run(context: Dict[str, Any] | None = None) Dict[str, Any][source]
Main entry point to run the agent
- Parameters:
context – Execution context
- Returns:
Execution result
- Raises:
AgentValidationError – If the context is invalid
AgentExecutionError – If an error occurs during execution
- class django_agents.base.AsyncAgent[source]
Base class for asynchronous agents.
Extends BaseAgent and adds support for asynchronous execution through Celery or other task queues.
- class django_agents.base.WorkflowAgent[source]
Agent specialized in managing workflows.
A workflow is a sequence of agents executed in a defined order.