Skip to main content

Simple AI agent framework with cloud tool support

Project description

Poping SDK v2

Pythonic AI agent framework with cloud tool support.

Architecture

poping/ (SDK)
├── __init__.py          # Public API
├── client.py            # Backend API client
├── agent.py             # Agent builder + session
├── tool.py              # @tool decorator + registry
├── exceptions.py        # Custom exceptions
└── README.md

backend/api/ (Backend)
└── server.py            # FastAPI server

Quick Start

1. Install Dependencies

pip install requests  # SDK only needs requests
pip install fastapi uvicorn pydantic  # Backend server

2. Start Backend API

cd backend/api
python server.py

Backend runs on http://localhost:8000

3. Use SDK

import poping

# Define local tool
@poping.tool(name="calc.add")
def add(a: float, b: float) -> float:
    """Add two numbers"""
    return a + b

# Build agent with local + cloud tools
agent = (
    poping.agent(llm="claude-3-5-sonnet-20241022")
    .with_memory(session={"strategy": "summary"}, toolset=True)
    .with_knowledge(["kb_docs"], toolset=True)
    .with_tool(
        local=[add],  # Local tools
        cloud=["memory.add", "knowledge.search"]  # Cloud tools
    )
    .build(api_key="your_api_key")
)

# Chat
with agent.session(user_id="user_123") as conv:
    response = conv.chat("Remember that I like Python")
    # → Agent auto-detects and executes cloud tool 'memory.add'
    print(response)

Key Features

1. Local + Cloud Tools

Local tools - Python functions decorated with @tool:

@poping.tool(name="search.web")
def search_web(query: str) -> str:
    """Search the web"""
    return f"Results for: {query}"

Cloud tools - Backend-hosted services:

  • memory.add - Add memory item
  • memory.search - Search memory
  • knowledge.search - Search knowledge base
  • knowledge.query - RAG query
  • data.query - Query dataset
  • data.search - Semantic search

Auto-detection: When LLM decides to use a tool, SDK automatically:

  1. Checks if tool is local → executes Python function
  2. Checks if tool is cloud → calls backend API
  3. Returns result to LLM

2. Backend Integration

SDK communicates with backend via REST API:

SDK Tool Execution Flow:
1. Agent receives message from user
2. LLM decides to use tool (e.g., "memory.add")
3. SDK checks tool registry:
   - Local? Execute function directly
   - Cloud? Call POST /api/v1/tools/execute
4. Backend routes to appropriate module (memory, knowledge, data)
5. Backend executes and returns result
6. SDK sends result back to LLM
7. LLM generates final response

3. Toolset Strategies

When you enable toolset=True on modules:

agent = (
    poping.agent(llm="...")
    .with_memory(toolset=True)  # Adds: memory.add, memory.search
    .with_knowledge(["kb_docs"], toolset=True)  # Adds: knowledge.search, knowledge.query
    .with_data(["ds_users"], toolset=True)  # Adds: data.query, data.search
    .build()
)

SDK automatically registers corresponding cloud tools.

4. Tool Override

Control tool availability per message:

with agent.session(user_id="user_123") as conv:
    # Use all configured tools
    conv.chat("Search the docs")

    # Use specific tools only
    conv.chat("Search memory", tool=["memory.search"])

    # Disable all tools
    conv.chat("Just answer", tool=False)

API Endpoints

Backend exposes these endpoints:

Tools

  • GET /api/v1/tools/list - List cloud tools
  • POST /api/v1/tools/execute - Execute cloud tool

LLM

  • POST /api/v1/llm/create - Single LLM call (SDK owns tool loop)

Memory

  • POST /api/v1/memory/{memory_id}/items - Add memory
  • GET /api/v1/memory/{memory_id}/search - Search memory

Knowledge

  • GET /api/v1/knowledge/{kb_id}/search - Search KB
  • POST /api/v1/knowledge/{kb_id}/query - RAG query

Data

  • POST /api/v1/data/{dataset_id}/records - Insert record
  • POST /api/v1/data/{dataset_id}/query - Query dataset
  • GET /api/v1/data/{dataset_id}/search - Semantic search

Environment Variables

export POPING_API_KEY="your_api_key"
export POPING_BASE_URL="http://localhost:8000"  # Optional

Then SDK automatically picks up credentials:

agent = poping.agent(llm="...").build()  # No api_key needed

Example

See examples/sdk_example.py for complete example with:

  • Local tools (@tool decorator)
  • Cloud tools (memory, knowledge)
  • Session management
  • Tool overrides
  • Direct tool execution

Implementation Status

✅ Complete:

  • SDK structure (client, agent, tool, exceptions)
  • @tool decorator for local tools
  • Agent builder pattern
  • Session management with context manager
  • Tool registry (local + cloud)
  • Backend API server structure
  • Cloud tool endpoints

🔲 TODO:

  • Connect backend API to actual backend modules
  • Implement LLM integration (Claude API)
  • Implement tool call detection and execution loop
  • Add streaming support
  • Add async/await support
  • Add proper authentication/authorization
  • Add rate limiting
  • Add comprehensive error handling

Design Principles

  1. Simple API - Pythonic, intuitive, minimal boilerplate
  2. Cloud tool auto-detection - SDK handles local vs cloud transparently
  3. Flexible tool strategies - Mix local and cloud tools as needed
  4. Backend integration - Clean separation between SDK and backend
  5. Session-based - Context manager for automatic cleanup

Next Steps

  1. Backend implementation: Connect API endpoints to backend modules
  2. LLM integration: Add Anthropic Claude API calls
  3. Tool execution: Implement complete tool call loop
  4. Testing: Add unit and integration tests
  5. Documentation: API reference and guides

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

poping-0.0.2.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

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

poping-0.0.2-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file poping-0.0.2.tar.gz.

File metadata

  • Download URL: poping-0.0.2.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for poping-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6e9da500782b7f8299b9631dfc7126ea5cbd7a3b958ed52a206d263b8c6203fc
MD5 1952e51c5a163d676568b1d324f3e27e
BLAKE2b-256 a598b6270e17eb7e85be542942a621785f900db8fba4dfaf3bb761ce4fa7d698

See more details on using hashes here.

File details

Details for the file poping-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: poping-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for poping-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 400a3cb1ed3e5cd56c100e3160054512d2475d2375529628bdead6105e491bf8
MD5 94b56ca2ebb61d0e189233a970cbc472
BLAKE2b-256 67d0265aae5ba0d9de6e6c4e6a2943c35bfeb0f714fb44bcf7735267e6169eef

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