Skip to main content

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


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)

Uploaded Source

Built Distribution

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

elasticdash_test-0.1.2a2-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

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

Hashes for elasticdash_test-0.1.2a2.tar.gz
Algorithm Hash digest
SHA256 81c44fdff2883d4362ddf9e26b3a823470e84c444e6da0c84a07d2a61e9a5e0e
MD5 02ffee92eda14045bf9bf6e83e321544
BLAKE2b-256 cbeeefbe77356ca913959bc3efa745f400bb131220e4d3756289f29bed30589c

See more details on using hashes here.

File details

Details for the file elasticdash_test-0.1.2a2-py3-none-any.whl.

File metadata

File hashes

Hashes for elasticdash_test-0.1.2a2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc23f20f2332b3b9bac3dd68e9603840f0706ed36e85a9d7efda930e2f519a28
MD5 3c5968ef75f4fe5e3e34ebed15714cba
BLAKE2b-256 762526c503ef38da2ff1c9b9457418d010991ff725c0eef09db538854362c9fb

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