Skip to main content

A modular AI agent framework supporting OpenAI and Anthropic models

Project description


Pixelagent: An Agent Engineering Blueprint

We see agents as the intersection of an LLM, storage, and orchestration. Pixeltable unifies this interface into a single declarative framework, making it the de-facto choice for engineers to build custom agentic applications with build-your-own functionality for memory, tool-calling, and more.

Build your own agent framework:

  • Data Orchestration and Storage: Built on Pixeltable's data infrastructure
  • Native Multimodal: Built-in support for text, images, audio and video
  • Declarative Model: A type-safe python framework
  • Model agnostic: Extensible to multiple providers
  • Observability: Complete traceability with automatic logging of messages, tool calls, and performance metrics
  • Agentic Extensions: Add reasoning, reflection, memory, knowledge, and team workflows.

Connect blueprints to Cursor, Windsurf, Cline:

Plug-and-Play Extensions

Usage

Transform your agent blueprint into a distributable package on PyPI, extending the build-your-own philosophy to deployment and sharing.

Installation

pip install pixelagent
# Install provider-specific dependencies
pip install anthropic  # For Claude models
pip install openai     # For GPT models

Quick Start

from pixelagent.anthropic import Agent  # Or from pixelagent.openai import Agent

# Create a simple agent
agent = Agent(
    name="my_assistant",
    system_prompt="You are a helpful assistant."
)

# Chat with your agent
response = agent.chat("Hello, who are you?")
print(response)

Adding Tools

import pixeltable as pxt
from pixelagent.anthropic import Agent
import yfinance as yf

# Define a tool as a UDF
@pxt.udf
def stock_price(ticker: str) -> dict:
    """Get stock information for a ticker symbol"""
    stock = yf.Ticker(ticker)
    return stock.info

# Create agent with tool
agent = Agent(
    name="financial_assistant",
    system_prompt="You are a financial analyst assistant.",
    tools=pxt.tools(stock_price)
)

# Use tool calling
result = agent.tool_call("What's the current price of NVDA?")
print(result)

State management

import pixeltable as pxt

# Agent memory is automatically persisted in tables
memory = pxt.get_table("my_assistant.memory")
conversations = memory.collect()

# Access tool call history
tools_log = pxt.get_table("financial_assistant.tools")
tool_history = tools_log.collect()

# cusomatizable memory database
conversational_agent = Agent(
    name="conversation_agent",
    system_prompt="Focus on remebering the conversation",
    n_latest_messages=14
)

Custom Agentic Strategies

# ReAct pattern for step-by-step reasoning and planning
import re
from datetime import datetime
from pixelagent.openai import Agent
import pixeltable as pxt

# Define a tool
@pxt.udf
def stock_info(ticker: str) -> dict:
    """Get stock information for analysis"""
    import yfinance as yf
    stock = yf.Ticker(ticker)
    return stock.info

# ReAct system prompt with structured reasoning pattern
REACT_PROMPT = """
Today is {date}

IMPORTANT: You have {max_steps} maximum steps. You are on step {step}.

Follow this EXACT step-by-step reasoning and action pattern:

1. THOUGHT: Think about what information you need to answer the question.
2. ACTION: Either use a tool OR write "FINAL" if you're ready to give your final answer.

Available tools:
{tools}

Always structure your response with these exact headings:

THOUGHT: [your reasoning]
ACTION: [tool_name] OR simply write "FINAL"
"""

# Helper function to extract sections from responses
def extract_section(text, section_name):
    pattern = rf'{section_name}:?\s*(.*?)(?=\n\s*(?:THOUGHT|ACTION):|$)'
    match = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
    return match.group(1).strip() if match else ""

# Execute ReAct planning loop
def run_react_loop(question, max_steps=5):
    step = 1
    while step <= max_steps:
        # Dynamic system prompt with current step
        react_system_prompt = REACT_PROMPT.format(
            date=datetime.now().strftime("%Y-%m-%d"),
            tools=["stock_info"],
            step=step,
            max_steps=max_steps,
        )
        
        # Agent with updated system prompt
        agent = Agent(
            name="financial_planner",
            system_prompt=react_system_prompt,
            reset=False,  # Maintain memory between steps
        )
        
        # Get agent's response for current step
        response = agent.chat(question)
        
        # Extract action to determine next step
        action = extract_section(response, "ACTION")
        
        # Check if agent is ready for final answer
        if "FINAL" in action.upper():
            break
            
        # Call tool if needed
        if "stock_info" in action.lower():
            tool_agent = Agent(
                name="financial_planner",
                tools=pxt.tools(stock_info)
            )
            tool_agent.tool_call(question)
            
        step += 1
    
    # Generate final recommendation
    return Agent(name="financial_planner").chat(question)

# Run the planning loop
recommendation = run_react_loop("Create an investment recommendation for AAPL")

Check out our tutorials for more examples including reflection loops, planning patterns, and multi-provider implementations.

Tutorials and Examples

  • Basics: Check out Getting Started for a step-by-step introduction to core concepts
  • Advanced Patterns: Explore Reflection and Planning for more complex agent architectures
  • Specialized Directories: Browse our example directories for deeper implementations of specific techniques

Ready to start building? Dive into the blueprints, tweak them to your needs, and let Pixeltable handle the AI data infrastructure while you focus on innovation!

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

pixelagent-0.1.5.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

pixelagent-0.1.5-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file pixelagent-0.1.5.tar.gz.

File metadata

  • Download URL: pixelagent-0.1.5.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for pixelagent-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2f7763c38c4d8dbd5134da52f7595a121dd8c439b8e06c373bea41ac1729102a
MD5 3fb15fc6085644baef4a08bb5016ebcf
BLAKE2b-256 1090e6343ac17bc7661726bca3116553b9af43c3a58bb37262f1e7d11aede63b

See more details on using hashes here.

File details

Details for the file pixelagent-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pixelagent-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for pixelagent-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7e97a847e0f50a6301f89929179dbcaf095c915ccc04d63597c1ac8d63ed00b3
MD5 ba61bcf2da13c4d8b98c5ae3a22fca1d
BLAKE2b-256 1259f2076a407aefc86c4cb03188177398bb9626794251294f017da20b5c9e79

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