Skip to content

Commit d3693c9

Browse files
committed
refactor(gepa): apply code cleanup principles consistently
- Use tuple syntax for startswith() (more Pythonic) - Remove unnecessary try-except for JSON parsing (we control the source) These follow the same principles applied in build_program refactor.
1 parent ecb3726 commit d3693c9

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

dspy/teleprompt/gepa/gepa_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def propose_component_texts(
161161
instruction_components = []
162162

163163
for c in components_to_update:
164-
if c.startswith(REACT_MODULE_PREFIX) or c.startswith(TOOL_MODULE_PREFIX):
164+
if c.startswith((REACT_MODULE_PREFIX, TOOL_MODULE_PREFIX)):
165165
tool_module_components.append(c)
166166
else:
167167
instruction_components.append(c)

dspy/teleprompt/gepa/instruction_proposal.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,7 @@ def __call__(
383383
continue
384384

385385
# Deserialize module config
386-
try:
387-
current_module_config = json.loads(candidate[module_key])
388-
except json.JSONDecodeError as e:
389-
logger.error(f"Failed to deserialize config for {module_key}: {e}")
390-
continue
386+
current_module_config = json.loads(candidate[module_key])
391387

392388
# Extract predictor keys (all keys except "tools")
393389
# Predictor keys are expected to be 1 for tool modules and 2 for ReAct modules (extra extract predictor)

0 commit comments

Comments
 (0)