agentle.agents.agent¶
The main module of the Agentle framework for creating and managing AI agents.
This module contains the definition of the Agent class, which is the central component of the Agentle framework. It allows you to create intelligent agents capable of processing different types of input, using external tools, and generating structured responses. The Agent facilitates integration with different AI model providers and supports a wide variety of input formats.
Basic example: ```python from agentle.generations.providers.google.google_generation_provider import GoogleGenerationProvider from agentle.agents.agent import Agent
- weather_agent = Agent(
generation_provider=GoogleGenerationProvider(), model=”gemini-2.0-flash”, instructions=”You are a weather agent that can answer questions about the weather.”, tools=[get_weather],
)
output = weather_agent.run(“Hello. What is the weather in Tokyo?”) ```
Functions
|
!!! abstract "Usage Documentation" |
|
@asynccontextmanager decorator. |
|
Cast a value to a type. |
|
@contextmanager decorator. |
|
|
|
Get the default global suspension manager instance. |
|
Check if a module is available without importing it. |
|
Runs a callable synchronously. |
Classes
|
The main class of the Agentle framework that represents an intelligent agent. |
|
Configuration class for Agentle agents. |
|
Configuration class for Agentle agents. |
|
Represents the complete result of an agent execution. |
|
Represents a specific capability that an agent can perform. |
|
Special type indicating an unconstrained type. |
|
Represents a message from an assistant in the system. |
|
|
|
Represents authentication information for secure communication. |
|
Alias for pydantic.BaseModel. |
|
Buffered I/O implementation using an in-memory bytes buffer. |
|
|
|
Represents the capabilities of an agent in the A2A protocol. |
|
Alias for pydantic.ConfigDict. |
|
Container for contextual information that guides an agent's behavior. |
|
Represents a message from a developer in the system. |
|
Abstract base class for cache stores used in document parsing. |
|
Abstract base class for all document parsers in the Agentle framework. |
|
Represents a file attachment part of a message. |
|
Primary container for AI-generated content with metadata. |
|
Abstract base class for AI generation service providers. |
|
|
|
Thread-safe in-memory cache store for parsed documents. |
|
Abstract base class defining the protocol for MCP servers. |
|
A Mapping is a generic container for associating key/value pairs. |
|
A class that safely handles optional chaining for Python objects, emulating the ?. operator found in languages like JavaScript. |
|
An immutable sequence of messages with functional manipulation methods. |
|
A MutableMapping is a generic container for associating key/value pairs. |
|
All the operations on a read-write sequence. |
|
Represents a fully parsed document with its sections and metadata. |
|
PurePath subclass that can make system calls. |
|
Represents a text prompt that can contain template expressions. |
|
Tracks the state of an agent's execution. |
|
All the operations on a read-only sequence. |
|
|
|
Static knowledge is a collection of knowledge that is provided to the agent at the time of creation. |
|
Represents a single execution step in an agent's reasoning process. |
|
Text I/O implementation using an in-memory buffer. |
|
Manages suspended agent executions for Human-in-the-Loop workflows. |
|
Represents a plain text part of a message. |
|
A callable tool that can be used by AI models to perform specific functions. |
|
Represents a suggestion to execute a specific tool. |
|
Parameters for tracking and analyzing LLM interactions. |
|
Represents a message from a user in the system. |
Exceptions
|
Exception raised when an agent exceeds its configured maximum number of tool calls. |
|
Exception raised by tools to suspend agent execution for external input. |