Record/replay testing for LLM agents - VCR.py but for LLM SDKs
Project description
agentape
Record/replay testing for LLM agents. Think "VCR.py but for LLM SDKs" with semantic matching.
Installation
pip install agentape
Quick Start
import agentape
from openai import OpenAI
# Wrap the client
client = agentape.wrap(OpenAI())
# Record interactions
with agentape.record("tapes/my_flow.yaml"):
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)
# Replay interactions (no API calls made)
with agentape.replay("tapes/my_flow.yaml"):
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)
pytest Integration
import agentape
@agentape.use_tape("tapes/{test_name}.yaml")
def test_my_feature(openai_client):
response = openai_client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)
assert "hello" in response.choices[0].message.content.lower()
Run tests with:
pytest tests/ --tape-mode=record # Record new tapes
pytest tests/ --tape-mode=replay # Replay existing (default)
pytest tests/ --tape-mode=off # Pass-through, no taping
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
agentape-0.1.0.tar.gz
(17.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
agentape-0.1.0-py3-none-any.whl
(14.0 kB
view details)
File details
Details for the file agentape-0.1.0.tar.gz.
File metadata
- Download URL: agentape-0.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34157b989bb1ae1b8089925330ab6b420ee9bbf595898797ae28a762fafb720b
|
|
| MD5 |
6a154e72922390969c77af960353f1ca
|
|
| BLAKE2b-256 |
a6be526a53432dd2daa1eff5a21e6a0070099a97875eb4fcd12b9c8a6189b331
|
File details
Details for the file agentape-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentape-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2330405937f8b6446b39a26e1dcf37a5f3789c57f783fb858996a75d69ba79be
|
|
| MD5 |
81b77d3f50f172334423493a9eafbf1e
|
|
| BLAKE2b-256 |
8ecfbcdf29f410a7b3800ee09a237a3d72e657e5eec29df40aa78077ba6035b1
|