Elasticdash AI test framework for Python
Project description
elasticdash_test
Python port of the Elasticdash AI test framework.
Install
pip install elasticdash_test
Usage
elasticdash test
elasticdash test ./examples
elasticdash run examples/simple_flow.ai_test.py
OPENAI_API_KEY is required for semantic matchers that call an LLM judge.
See docs/test-writing-guidelines.md for authoring tips.
Writing a test (quick example)
# examples/checkout_flow.ai_test.py
from elasticdash_test import ai_test, before_all, before_each, after_each, install_ai_interceptor, uninstall_ai_interceptor, expect
@before_all
def setup_suite():
# Capture httpx/requests LLM calls automatically
install_ai_interceptor()
@after_each
def teardown_each(ctx):
# You can assert cleanup steps here
ctx.trace.record_custom_step(kind="teardown", name="after-each")
@ai_test("checkout confirms order")
async def test_checkout(ctx):
# Your app code runs here (sync or async). Simulate trace records:
ctx.trace.record_llm_step(model="gpt-4o-mini", provider="openai", prompt="confirm order?", completion="order confirmed")
ctx.trace.record_tool_call(name="chargeCard", args={"amount": 42})
# Assertions on trace
expect(ctx.trace).to_have_llm_step(model="gpt-4o-mini", contains="confirmed")
expect(ctx.trace).to_call_tool("chargeCard")
# Optional semantic judge (needs OPENAI_API_KEY)
await expect(ctx.trace).to_match_semantic_output("order confirmed")
Run it:
elasticdash run examples/checkout_flow.ai_test.py
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
elasticdash_test-0.1.2a2.tar.gz
(16.6 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
File details
Details for the file elasticdash_test-0.1.2a2.tar.gz.
File metadata
- Download URL: elasticdash_test-0.1.2a2.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81c44fdff2883d4362ddf9e26b3a823470e84c444e6da0c84a07d2a61e9a5e0e
|
|
| MD5 |
02ffee92eda14045bf9bf6e83e321544
|
|
| BLAKE2b-256 |
cbeeefbe77356ca913959bc3efa745f400bb131220e4d3756289f29bed30589c
|
File details
Details for the file elasticdash_test-0.1.2a2-py3-none-any.whl.
File metadata
- Download URL: elasticdash_test-0.1.2a2-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc23f20f2332b3b9bac3dd68e9603840f0706ed36e85a9d7efda930e2f519a28
|
|
| MD5 |
3c5968ef75f4fe5e3e34ebed15714cba
|
|
| BLAKE2b-256 |
762526c503ef38da2ff1c9b9457418d010991ff725c0eef09db538854362c9fb
|