Skip to main content

Production-ready boilerplate for common agentic AI patterns in Python

Project description

agent-patterns

A Python framework for building production-ready AI agents using the GAME pattern (Goals, Actions, Memory, Environment).


Install

git clone https://github.com/your-username/agent-patterns.git
cd agent-patterns
uv sync
cp .env.example .env  # add your API keys

Quick start

import os
from agent_patterns import (
    Agent, Goal,
    PythonEnvironment,
    AgentFunctionCallingActionLanguage,
    PythonActionRegistry,
    register_tool,
    make_generate_response,
)

@register_tool(tags=["files"])
def list_files() -> list:
    """List files in the current directory."""
    return os.listdir(".")

@register_tool(tags=["files"])
def read_file(name: str) -> str:
    """Read a file and return its contents."""
    with open(name) as f:
        return f.read()

@register_tool(tags=["system"], terminal=True)
def terminate(message: str) -> str:
    """End the session with a final message."""
    return message

agent = Agent(
    goals=[
        Goal(1, "Explore", "List and read files in the current directory."),
        Goal(2, "Terminate", "Call terminate with a summary when done."),
    ],
    agent_language=AgentFunctionCallingActionLanguage(),
    action_registry=PythonActionRegistry(tags=["files", "system"]),
    generate_response=make_generate_response("openai/gpt-4o"),
    environment=PythonEnvironment(),
)

memory = agent.run("What Python files are here and what do they do?")

Docs


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

agent_patterns_py-0.1.0.tar.gz (191.0 kB view details)

Uploaded Source

Built Distribution

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

agent_patterns_py-0.1.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file agent_patterns_py-0.1.0.tar.gz.

File metadata

  • Download URL: agent_patterns_py-0.1.0.tar.gz
  • Upload date:
  • Size: 191.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_patterns_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f4192da898d7de4b21113e275ebf3d4ffa8f7bb0ee44f6dd5b1e67d07289c53
MD5 69704907b69e4b0a0b0204c2e1d76688
BLAKE2b-256 b86ae1ebecef5eb87819798907236c479bac649df8c0fb5c322f8516f308b6cb

See more details on using hashes here.

File details

Details for the file agent_patterns_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_patterns_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_patterns_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8294c1a5022fb2a108d97470708612c1a49016cf248d581b120a99f5073ef0
MD5 c521a1f78c32dd94ce16a11e231e139a
BLAKE2b-256 6476e9958bdc5f96288938b48be7be49c042cb8284057650ed5e80268cf111e9

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