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.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trulens_apps_gepa-2.14.0.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trulens_apps_gepa-2.14.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.0 kB
Release files / trulens_apps_gepa-2.14.0.tar.gz
| Download URL | trulens_apps_gepa-2.14.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f87fe50c75feaf556fc3e9ed6f613e0bc53f7348241b60715ec7aeb4118ab955
|
|
BLAKE2b-256 checksum How to use checksums |
66231b7c64ac4c59ff29d3e35fffb57d58f4601038aa87c74bca3b8ad4aef98f
|
| 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.14.0-py3-none-any.whl
| Download URL | trulens_apps_gepa-2.14.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9aad0726bdb0566413d79cf0d8226958204ceba57f77b23aa43e1b0c4baaacb
|
|
BLAKE2b-256 checksum How to use checksums |
46da2ef34fe42eba8634c0411e636ece233925b4620bd275882f2cd1cfd56b71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.16
|