Creating an Agent

Create an AI agent with specific capabilities:

agent = client.agents.create(
    name="Research Assistant",
    model="claude-3.5-sonnet",  # or any supported model
    about="A helpful research assistant that can search and summarize information.",
    metadata={
        "expertise": "research",
        "language": "english"
    }
)

Retrieving Agents

# Get a specific agent
agent = client.agents.get(agent_id="agent_123")

# List all agents
agents = client.agents.list(
    limit=10,
    offset=0,
    metadata_filter={"expertise": "research"}
)

Updating Agents

updated_agent = client.agents.update(
    agent_id="agent_123",
    name="Advanced Research Assistant",
    metadata={"expertise": ["research", "analysis"]}
)

Managing Agent Tools

Add capabilities to your agent by attaching tools:

# Add a web search tool
client.agents.tools.create(
    agent_id=agent.id,
    name="web_search",
    description="Search the web for information",
    integration={
        "provider": "brave",
        "method": "search",
        "setup": {"api_key": "your_brave_api_key"}
    }
)

# List agent's tools
tools = client.agents.tools.list(agent_id=agent.id)

# Remove a tool
client.agents.tools.delete(
    agent_id=agent.id,
    tool_id="tool_123"
)

Working with Documents

Manage documents associated with your agent:

# Add a document
doc = client.agents.docs.create(
    agent_id=agent.id,
    title="Research Paper",
    content="Content of the research paper...",
    metadata={"category": "science"}
)

# Search documents
results = client.agents.docs.search(
    agent_id=agent.id,
    text="quantum physics",
    metadata_filter={"category": "science"},
    limit=5
)

# Delete a document
client.agents.docs.delete(
    agent_id=agent.id,
    doc_id="doc_123"
)

Deleting Agents

client.agents.delete(agent_id="agent_123")

Error Handling

from julep.exceptions import JulepError, AgentNotFoundError

try:
    agent = client.agents.get("nonexistent_id")
except AgentNotFoundError:
    print("Agent not found")
except JulepError as e:
    print(f"An error occurred: {e}")