Skip to main content

Add your description here

Project description

Agentique

Agentique is a Python framework for creating agentic AI systems that can interact with their environment through function calls and communicate with other agents.

Features

  • Multi-model support: Use OpenAI or Anthropic models
  • Tool integration: Enable AI agents to call functions, APIs, and services
  • Agent communication: Allow agents to message and collaborate with each other
  • Structured outputs: Define custom structured output formats using Pydantic models
  • Conversation management: Maintain and manipulate conversation history
  • Robust error handling: Retry logic for API calls with exponential backoff

Installation

pip install agentique

Quick Start

import asyncio
import os
from pydantic import BaseModel, Field
from agentique import Agentique, StructuredResult

# Define a custom output structure (optional)
class AnalysisResult(StructuredResult):
    summary: str = Field(..., description="Brief summary of the analysis")
    key_points: list[str] = Field(..., description="List of key points")
    sentiment: str = Field(..., description="Overall sentiment")

# Create a custom tool
async def get_data(query: str):
    """Get data based on a query"""
    # Implementation would call an API or database
    return {"data": f"Results for: {query}"}

async def main():
    # Initialize Agentique with API keys
    agentique = Agentique(
        openai_api_key=os.environ["OPENAI_API_KEY"],
        anthropic_api_key=os.environ.get("ANTHROPIC_API_KEY")  # Optional
    )
    
    # Register custom tools
    agentique.register_tool(
        name="get_data",
        function=get_data,
        description="Get data based on a query string"
    )
    
    # Create an agent with a custom output structure
    agent = agentique.create_agent(
        agent_id="analyst",
        system_prompt="You are a data analyst. Analyze data and provide insights.",
        structured_output_model=AnalysisResult
    )
    
    # Run the agent with a query
    result = await agent.run(
        user_input="Analyze the latest market trends",
        tools=["get_data"]
    )
    
    # Handle structured output
    if isinstance(result, AnalysisResult):
        print(f"Summary: {result.summary}")
        print(f"Key Points: {result.key_points}")
        print(f"Sentiment: {result.sentiment}")
    else:
        print(f"Response: {result}")

if __name__ == "__main__":
    asyncio.run(main())

Core Components

  • Agentique: Main interface for creating and managing agents
  • Agent: Handles interactions with AI models, maintains conversation history
  • ToolRegistry: Manages available tools that agents can use
  • StructuredResult: Base model for structured outputs
  • OpenAIClientWrapper/AnthropicClientWrapper: API client wrappers with retry logic

Customization

Custom Output Structures

Define your own structured output format by subclassing StructuredResult:

from pydantic import BaseModel, Field
from agentique import StructuredResult

class ResearchReport(StructuredResult):
    title: str = Field(..., description="Report title")
    findings: list[str] = Field(..., description="Key research findings")
    recommendations: list[str] = Field(..., description="Recommended actions")
    confidence: float = Field(..., ge=0, le=1, description="Confidence level")

Custom Tools

Register custom functions as tools for your agents:

# Synchronous tool
def calculate_metric(data: list[float], method: str = "mean"):
    """Calculate statistical metrics from a list of values"""
    if method == "mean":
        return sum(data) / len(data)
    elif method == "max":
        return max(data)
    # ...etc.

# Register the tool
agentique.register_tool(
    name="calculate_metric",
    function=calculate_metric,
    description="Calculate statistical metrics from data"
)

Multi-Agent Systems

Create multiple agents that can communicate with each other:

# Create agents with different roles
researcher = agentique.create_agent(
    agent_id="researcher",
    system_prompt="You research facts and information."
)

writer = agentique.create_agent(
    agent_id="writer",
    system_prompt="You write engaging content based on research."
)

# Have agents communicate
from agentique import message_agent

async def coordinate_agents():
    # Get research from the researcher
    research_result = await message_agent(
        target_agent_id="researcher",
        message="Research the history of artificial intelligence."
    )
    
    # Pass the research to the writer
    content = await message_agent(
        target_agent_id="writer",
        message=f"Write an article based on this research: {research_result}"
    )
    
    return content

API Reference

For full API documentation, see the API Reference.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentique-0.1.1.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentique-0.1.1-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file agentique-0.1.1.tar.gz.

File metadata

  • Download URL: agentique-0.1.1.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for agentique-0.1.1.tar.gz
Algorithm Hash digest
SHA256 05790c819ce267120961354dd57f404301802ffb9c7f5a4b4b00c30b13771dfd
MD5 166ebda7b22aaf593f396a4772865e68
BLAKE2b-256 8fea5d29d21b63ff926adc112133b0b34e19fb07901e85f2f1e5683d7f6ceb18

See more details on using hashes here.

File details

Details for the file agentique-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agentique-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for agentique-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5458b0d8aeca5495674f4871d3ca747c274f33cd70fcee89546c9f54d08123ea
MD5 af4e8fab7052258c560639e8863a8a6d
BLAKE2b-256 65a619e393174c9bde66091795d13c137c38a376b236fdce6c4b9e585c17ebac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page