A small function.
A better program.
The evaluator is your specification. It tells the search which candidates deserve another generation.
1. Install
Python 3.11 or later.
pip install easyevolveDeveloper preview: the package is not on PyPI yet. Until it is, install it from the service repository with pip install -e . and point the SDK at your API with EASYEVOLVE_API_URL.
2. Define what to improve
Expose a synchronous evaluate(candidate_path: str) → dict. The required score is a finite number; higher is better. Use the Python standard library.
import importlib.util
def evaluate(candidate_path: str) -> dict:
spec = importlib.util.spec_from_file_location("candidate", candidate_path)
candidate = importlib.util.module_from_spec(spec)
spec.loader.exec_module(candidate)
cases = [[], [1], [3, 1, 2], [5, -1, 5, 0], list(range(30, 0, -1))]
passed = sum(candidate.solve(x.copy()) == sorted(x) for x in cases)
return {"score": passed / len(cases)}Describe the candidate’s function name and input/output contract in your evaluator. If it is hard to infer, add a task when creating the client.
3. Start an evolution
from easyevolve import EasyEvolve
with EasyEvolve(
evaluator="eval.py",
task="Implement solve(values), returning a sorted list"
) as client:
result = client.run(iterations=100, level="low", budget=2.0)
print(result.best_code)
print(result.best_score)
print(result.cost)The service generates and evaluates the initial code before attempting mutations. The initial candidate is recorded as iteration 0. The requested iteration count is the number of subsequent attempts.
Reconnect, inspect, or cancel
with EasyEvolve() as client:
result = client.resume("your-job-id")
# client.progress("your-job-id")
# client.cancel("your-job-id")A client timeout leaves the server job running. Cancellation takes effect before the next operation; an in-flight call finishes and its reserved cost is settled.
Results include status, best_code, best_score, initial_score, cost, and history. Budget exhaustion can return the best candidate found so far. A failed run raises EasyEvolveError with the result attached.
Payment without an account form
The first run opens Stripe Checkout to purchase prepaid credits. The SDK stores a device token at ~/.config/easyevolve/credentials.json with owner-only file permissions. Additional credit purchases are required when your balance is too low.
You can call purchase_credits(), balance(), rotate_token(), and revoke_token() directly. In development, the operator can issue test credit using the service CLI.