Skip to main content

trulens-apps-gepa

TruLens adapter for GEPA (Genetic/Evolutionary Prompt Adaptation).

GEPA optimizes prompts using evolutionary algorithms. This package provides TruGEPA, a thin adapter that wraps any TruLens feedback callable as a GEPA-compatible fitness function and automatically logs every evaluation as a TruVirtual record for dashboard visibility, plus a simple run_evolution helper that implements the evolutionary loop.

Installation

pip install trulens-apps-gepa

Quick start

from trulens.apps.gepa import TruGEPA, run_evolution


def my_relevance(prompt: str) -> float:
    return len(prompt) / 200  # replace with a real TruLens provider method


# Without logging:
fitness = TruGEPA(my_relevance, optimize_key="prompt")

# With logging — supply both app_name and app_version (omit both to disable;
# supplying only one raises a ValueError immediately):
from trulens.core import TruSession

session = TruSession()

fitness = TruGEPA(
    my_relevance,
    optimize_key="prompt",
    app_name="my_optimizer",
    app_version="v1",
)

# Works with any feedback signature — e.g. context_relevance(question, context):
# fitness = TruGEPA(
#     provider.context_relevance,
#     optimize_key="question",
#     feedback_args={"context": REFERENCE_CONTEXT},
# )

best_prompt, best_score, history = run_evolution(
    base_prompt="Summarize the document.",
    fitness_fn=fitness,
    mutate_fn=lambda p: p + " Be concise.",
    n_generations=5,
    population_size=4,
)
print(f"Best prompt ({best_score:.3f}): {best_prompt}")

When both app_name and app_version are provided, a TruVirtual recorder is created automatically and every evaluation is logged. Omit both to run without any logging.

Metadata

Release files for trulens-apps-gepa 2.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trulens-apps-gepa 2.15.0
File Size Uploaded
trulens_apps_gepa-2.15.0.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trulens-apps-gepa 2.15.0
File Interpreter ABI Platform
trulens_apps_gepa-2.15.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 kB

Release files / trulens_apps_gepa-2.15.0.tar.gz

Download URL trulens_apps_gepa-2.15.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
206f1dbdf35fdaf710258f9ef789357dcafa5fcbc32cf923f4b340f90a564af3
BLAKE2b-256 checksum
How to use checksums
0f2b8764476b46884bd04295a5d741b8925e868fccd5b25d9b754a1ed3c40f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.16

Release files / trulens_apps_gepa-2.15.0-py3-none-any.whl

Download URL trulens_apps_gepa-2.15.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
010bbd3f49a8bce0ddda02605b5bba9fa1cac83ddbb91cf0c77d40e3a7d9de90
BLAKE2b-256 checksum
How to use checksums
2ea7f5f77365d4dbf7db50a3aa4682b9876f04779bed7adaccfcf2ad75dbc9dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

2.15.0 This release

2 release files

2.13.1

2 release files

2.13.0

2 release files

2.10.0

2 release files

2.9.0

2 release files

2.8.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page