Skip to main content

Python SDK for AOps — prompt version management

Project description

aops

PyPI Python

Python SDK for AOps — prompt version management and agent tracing platform.

Provides a framework-agnostic pull() that works with any LLM SDK, a run() context manager for execution tracing, and a LangChain integration.

Installation

pip install aops

With LangChain integration:

pip install "aops[langchain]"

Quick Start

Pull a prompt

import aops
from aops import pull
from openai import OpenAI

aops.init(api_key="aops_...", agent="my-agent")

system_prompt = pull("my-chain")  # agent resolved from init()

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": "Hello!"},
    ],
)
print(response.choices[0].message.content)

Record execution traces

Wrap your agent logic in aops.run() to automatically record which chains were called, in what order, and with what latency. The data is posted to the AOps backend and visualized in the Flow tab.

import aops

aops.init(api_key="aops_...", agent="my-agent")

# Chains pulled outside run() are not traced (good for shared system prompts)
system_prompt = aops.pull("system")

def handle(inquiry: str) -> str:
    with aops.run():
        classify_prompt = aops.pull("classify")      # traced
        category = classify(classify_prompt, inquiry)

        response_prompt = aops.pull(f"respond-{category}")  # traced
        return respond(system_prompt, response_prompt, inquiry)

On block exit, the SDK posts started_at, ended_at, and the ordered list of chain calls to POST /agents/:id/runs. If the backend is unreachable, a warning is logged and the exception is suppressed — your agent is never interrupted by a tracing failure.

Anthropic SDK

import aops
from aops import pull
from anthropic import Anthropic

aops.init(api_key="aops_...", agent="my-agent")

system_prompt = pull("my-chain")

client = Anthropic()
message = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=1024,
    system=system_prompt,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)

LangChain

import aops
from aops.langchain import pull
from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI

aops.init(api_key="aops_...", agent="my-agent")

prompt = pull("my-chain")

chain = (
    ChatPromptTemplate.from_messages([
        prompt,
        HumanMessagePromptTemplate.from_template("{user_input}"),
    ])
    | ChatOpenAI(model="gpt-4o-mini")
    | StrOutputParser()
)

result = chain.invoke({"user_input": "Hello!"})

Requirements

  • Python 3.12+
  • AOps backend running (self-hosted)
  • API key issued from the AOps UI: Agent detail page → API Keys → New API Key

Examples

examples/
  openai_example.py     raw pull() + OpenAI SDK
  anthropic_example.py  raw pull() + Anthropic SDK
  langchain_example.py  aops.langchain — pull(), @chain_prompt
  live_updates.py       background polling / live update detection

Docs

Guide Description
Configuration API key, aops.init(), environment variables
API Reference pull(), aops.langchain.pull(), @chain_prompt
Live Updates Polling, pattern selection guide
Run Tracing aops.run(), how traces are recorded and posted, async safety
LangChain Compatibility Class-based vs LCEL, RunnableLambda lazy-pull pattern

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

aops-0.5.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

aops-0.5.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file aops-0.5.0.tar.gz.

File metadata

  • Download URL: aops-0.5.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aops-0.5.0.tar.gz
Algorithm Hash digest
SHA256 074595febc982bda76685ce888e1da28c6d6ee81822ed0ed859dd63ad24ce708
MD5 300d8364472badb9994360e744498680
BLAKE2b-256 45cba11b7ce9285dd7b6ca20ebd37c19f47ced78e67c4e7e35fe538f09b2b356

See more details on using hashes here.

Provenance

The following attestation bundles were made for aops-0.5.0.tar.gz:

Publisher: release.yml on cow-coding/aops-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aops-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: aops-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aops-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2178d1174638cb086cb2c26bd658fb3ca4ee51fc358f09745a8fa9986d90d01
MD5 11b5eafa5c5e9ca248d0344816b70726
BLAKE2b-256 dc34ea73371e5c527e9c0607d1f245dd711bf2bc707606a8d07aa15e0e38237f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aops-0.5.0-py3-none-any.whl:

Publisher: release.yml on cow-coding/aops-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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