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.16.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.16.0
File Size Uploaded Provenance Actions
trulens_apps_gepa-2.16.0.tar.gz 4.4 kB Without provenance Details for trulens_apps_gepa-2.16.0.tar.gz

Built distribution (wheel)

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

Total release size: 10.0 kB

Release files / trulens_apps_gepa-2.16.0.tar.gz

Download URL trulens_apps_gepa-2.16.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b750450c80aed85b63bc8e3b5d7669904b40a033295336b3ce0752ec24da1e60
BLAKE2b-256 checksum
How to use checksums
07e9e709c30c1523d569d01a882014825f86626d2237965ea04fb40754ec141b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.17

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

Download URL trulens_apps_gepa-2.16.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5af2817b2affc7a1ae868470e8074726579aa544b448f060f1aab90bfeba3045
BLAKE2b-256 checksum
How to use checksums
847e20f6829f24444f1552610464757f1dbdbda2bfd53655ec62b1ffa86ab221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.17

Security for trulens-apps-gepa 2.16.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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