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.2a1.tar.gz
(15.9 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.2a1.tar.gz.
File metadata
- Download URL: elasticdash_test-0.1.2a1.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
273df6924656063214e0b4413847893ada3d2b255c08db1e899ffd79b436a3e9
|
|
| MD5 |
f0a2c935b47db9d42b61b1862033b44c
|
|
| BLAKE2b-256 |
6b2af6da16ee8cb4f20fd917bdf44f049d523c598a85fe1751db8e07d1cc9ff1
|
File details
Details for the file elasticdash_test-0.1.2a1-py3-none-any.whl.
File metadata
- Download URL: elasticdash_test-0.1.2a1-py3-none-any.whl
- Upload date:
- Size: 16.0 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 |
a66f178f907a520b84fb7f77a6e17ea5bae0d6937c0d88308d070c80e392bb03
|
|
| MD5 |
5f6aae3f543e27a6781c2bbaa046baf9
|
|
| BLAKE2b-256 |
c85f0878614f58fa3e2faf4064ba481a5667b58b3ce8954168ed1f58083680e5
|