Skip to main content

Elasticdash AI test framework for Python

Project description

elasticdash-test-py

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


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.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

elasticdash_test-0.1.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file elasticdash_test-0.1.1.tar.gz.

File metadata

  • Download URL: elasticdash_test-0.1.1.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

Hashes for elasticdash_test-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e0cb319f854326ba0c882259cceb4b691af3ac94164bd6dc77e8198806f11e8f
MD5 a14d88cfd9cb47c7163b95cd4250b797
BLAKE2b-256 2f015ad038d9309067f469a83c52d2fdca76fe5814fe69bf30cf36d23f62786d

See more details on using hashes here.

File details

Details for the file elasticdash_test-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for elasticdash_test-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 346d7d3e5ae9a41b8adb701ca1f1a1e94aabebb2076ff0275f1f1371b341ae8c
MD5 f4ae1c69f91f63716cc4f0c0982fecf6
BLAKE2b-256 55f25acfffa377019e3683ada18d63bca5b8b9cc095c36d1a49e4a332c75e2c7

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