Upgrade to DSPy 3.x (latest: 3.2.1) and add GEPA optimizer#2
Open
hammer-mt wants to merge 2 commits into
Open
Conversation
- Install 'dspy' instead of the deprecated 'dspy-ai' package, pinned to >=3.2.1, and uninstall any stale 'dspy-ai' from existing virtualenvs - Build custom signatures with dspy.Signature(fields_dict, instructions) instead of the pydantic create_model + multiple-inheritance workaround - Remove the MIPRO optimizer (removed in DSPy 3.x) from core.py and the UI dropdown - Update MIPROv2 to the new API: auto="medium" sizing instead of num_candidates/ num_batches, and drop the removed eval_kwargs/requires_permission_to_run args - Pass prompt_model to COPRO instead of the unused teacher_settings - Add the hint as a real signature input field for ChainOfThoughtWithHint, since dspy.ChainOfThoughtWithHint was removed and extra kwargs are now ignored - Read .score from Evaluate results, which now return EvaluationResult objects - Use the 'gemini/' LiteLLM prefix for Google models https://claude.ai/code/session_01LNCkRPkq52iz9gCgDnEpLH
GEPA (Genetic-Pareto) is the reflective prompt-evolution optimizer introduced in DSPy 3.x. Wraps the selected metric to GEPA's feedback-metric contract (extra pred_name/pred_trace args, score + textual feedback) and uses the teacher model as the reflection LM. Added to the optimizer dropdown. https://claude.ai/code/session_01LNCkRPkq52iz9gCgDnEpLH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades DSPyUI from the deprecated
dspy-ai2.x package to the latest DSPy release (3.2.1), updating all code paths that hit 3.x breaking changes, and adds support for the new GEPA optimizer.Changes
webui.shdspy>=3.2.1instead of the deprecateddspy-aipackage (renamed in 3.x)dspy-aifrom existing virtualenvs so returning users get cleanly upgradeddspy==3.*rather than matching any of the packagescore.pypydantic.create_model+ multiple-inheritance workaround with the supporteddspy.Signature(fields_dict, instructions)constructorMIPROoptimizer no longer exists in DSPy 3.x (from dspy.teleprompt import MIPROraises ImportError), so its branch is droppedauto="medium"run sizing; removednum_candidates/num_batches,eval_kwargs, and the deprecatedrequires_permission_to_runargumentsprompt_model=teacher_lm(its actual API) instead ofteacher_settings, which COPRO silently ignoreddspy.ChainOfThoughtWithHintwas removed and 3.x now ignores kwargs not in the signature (the old hint injection would have been silently dropped) — the hint is now appended to the signature as a proper input fieldEvaluate(...)()now returns anEvaluationResultobject, so scores are read via.scoregemini/LiteLLM prefix (google/is not a valid LiteLLM provider route)pred_name/pred_traceargs, returns score + textual feedback), with the teacher model used as the reflection LM andauto="light"run sizinginterface.pyMIPROfrom the optimizer dropdown, addedGEPA, and updated the help textTesting
Verified against DSPy 3.2.1 with a dummy LM (no API keys):
Predict,ChainOfThought,ChainOfThoughtWithHintincl. hint injection)compile_programrun withBootstrapFewShot+ Exact Match: baseline eval → compile → eval → program save → example usage with prompt-history extractioncompile_programrun withGEPA+ Exact Match end-to-endpy_compilepasses forcore.pyandinterface.pyhttps://claude.ai/code/session_01LNCkRPkq52iz9gCgDnEpLH