diff --git a/openevolve/database.py b/openevolve/database.py index a6ea4ff1..0b3292eb 100644 --- a/openevolve/database.py +++ b/openevolve/database.py @@ -65,6 +65,9 @@ class Program: # Metadata metadata: Dict[str, Any] = field(default_factory=dict) + # Prompts + prompts: Optional[Dict[str, Any]] = None + # Artifact storage artifacts_json: Optional[str] = None # JSON-serialized small artifacts artifact_dir: Optional[str] = None # Path to large artifact files diff --git a/openevolve/iteration.py b/openevolve/iteration.py index 2e3509df..ce854c93 100644 --- a/openevolve/iteration.py +++ b/openevolve/iteration.py @@ -119,6 +119,11 @@ async def run_iteration_with_shared_db( # Handle artifacts if they exist artifacts = evaluator.get_pending_artifacts(child_id) + # Set template_key of Prompts + template_key = ( + "full_rewrite_user" if not config.diff_based_evolution else "diff_user" + ) + # Create a child program result.child_program = Program( id=child_id, @@ -132,6 +137,13 @@ async def run_iteration_with_shared_db( "changes": changes_summary, "parent_metrics": parent.metrics, }, + prompts={ + template_key: { + "system": prompt["system"], + "user": prompt["user"], + "responses": [llm_response] if llm_response is not None else [], + } + } if database.config.log_prompts else None, ) result.prompt = prompt