Skip to content

Commit 025f00b

Browse files
authored
Merge pull request #251 from zigzagcai/refine-trace
refine(trace): save prompts in the checkpoint output folder
2 parents 6f20b85 + 154837e commit 025f00b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

openevolve/database.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class Program:
6565
# Metadata
6666
metadata: Dict[str, Any] = field(default_factory=dict)
6767

68+
# Prompts
69+
prompts: Optional[Dict[str, Any]] = None
70+
6871
# Artifact storage
6972
artifacts_json: Optional[str] = None # JSON-serialized small artifacts
7073
artifact_dir: Optional[str] = None # Path to large artifact files

openevolve/iteration.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ async def run_iteration_with_shared_db(
119119
# Handle artifacts if they exist
120120
artifacts = evaluator.get_pending_artifacts(child_id)
121121

122+
# Set template_key of Prompts
123+
template_key = (
124+
"full_rewrite_user" if not config.diff_based_evolution else "diff_user"
125+
)
126+
122127
# Create a child program
123128
result.child_program = Program(
124129
id=child_id,
@@ -132,6 +137,13 @@ async def run_iteration_with_shared_db(
132137
"changes": changes_summary,
133138
"parent_metrics": parent.metrics,
134139
},
140+
prompts={
141+
template_key: {
142+
"system": prompt["system"],
143+
"user": prompt["user"],
144+
"responses": [llm_response] if llm_response is not None else [],
145+
}
146+
} if database.config.log_prompts else None,
135147
)
136148

137149
result.prompt = prompt

0 commit comments

Comments
 (0)