Skip to content

Commit b55b268

Browse files
committed
fix(prompt): warn when custom template directory doesn't exist
1 parent ad9c9c1 commit b55b268

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

openevolve/prompt/templates.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
import os
66
import json
7+
import logging
78
from pathlib import Path
89
from typing import Dict, List, Optional, Union, Any
910

11+
logger = logging.getLogger(__name__)
12+
1013
# Base system message template for evolution
1114
BASE_SYSTEM_TEMPLATE = """You are an expert software developer tasked with iteratively improving a codebase.
1215
Your job is to analyze the current program and suggest improvements based on feedback from previous attempts.
@@ -185,8 +188,13 @@ def __init__(self, custom_template_dir: Optional[str] = None):
185188
self._load_from_directory(self.default_dir)
186189

187190
# 2. Override with custom templates (if provided)
188-
if self.custom_dir and self.custom_dir.exists():
189-
self._load_from_directory(self.custom_dir)
191+
if self.custom_dir:
192+
if self.custom_dir.exists():
193+
self._load_from_directory(self.custom_dir)
194+
else:
195+
logger.warning(
196+
f"Custom template directory does not exist, using default prompt."
197+
)
190198

191199
def _load_from_directory(self, directory: Path) -> None:
192200
"""Load all templates and fragments from a directory"""

0 commit comments

Comments
 (0)