Agent Class

The Agent class represents a specific agent within the xpander.ai platform. It provides capabilities to manage tasks, invoke tools, access knowledge bases, and manage agent properties.

Properties

id

id: str
Unique identifier for the agent.

name

name: str
Display name of the agent.

version

version: int
Current version number of the agent.

is_active

is_active: bool
Indicates whether the agent is currently active and available for use.

tools

tools: ToolsRepository
Object managing tools related to this agent.

Methods

`aload()

Asynchronously load additional agent details.
async def aload() - Agent
Returns: Complete Agent object with detailed configuration.

acreate_task(**kwargs)

Asynchronously create a new task for this agent.
async def acreate_task(
  prompt: str,
  **kwargs
) - Task
Example:
prompt = "What capabilities do you have?"
task = await agent.acreate_task(prompt=prompt)
print(f"Created task ID: {task.id}")

aget_knowledge_bases()

Asynchronously access knowledge bases linked to this agent.
async def aget_knowledge_bases() - List[KnowledgeBase]

Usage

Create and Manage Tasks

# Create a simple task
prompt = "Summarize this document"
task = await agent.acreate_task(prompt=prompt)
print(f"Created task ID: {task.id}")

# Advanced task creation
complex_task = await agent.acreate_task(
    prompt="Analyze these sales reports",
    file_urls=["https://example.com/report1.csv"],
    output_format=OutputFormat.Json
)

Manage Agent Tools

# Access agent's tools repository
for tool in agent.tools.function:
    print(f"Tool: {tool.name}")