Skip to content

Upgrade to DSPy 3.x (latest: 3.2.1) and add GEPA optimizer#2

Open
hammer-mt wants to merge 2 commits into
mainfrom
claude/dspy-version-upgrade-1Har6
Open

Upgrade to DSPy 3.x (latest: 3.2.1) and add GEPA optimizer#2
hammer-mt wants to merge 2 commits into
mainfrom
claude/dspy-version-upgrade-1Har6

Conversation

@hammer-mt

@hammer-mt hammer-mt commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Upgrades DSPyUI from the deprecated dspy-ai 2.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.sh

  • Installs dspy>=3.2.1 instead of the deprecated dspy-ai package (renamed in 3.x)
  • Uninstalls any stale dspy-ai from existing virtualenvs so returning users get cleanly upgraded
  • The install check now specifically looks for dspy==3.* rather than matching any of the packages

core.py

  • Signature creation: replaced the pydantic.create_model + multiple-inheritance workaround with the supported dspy.Signature(fields_dict, instructions) constructor
  • MIPRO removed: the MIPRO optimizer no longer exists in DSPy 3.x (from dspy.teleprompt import MIPRO raises ImportError), so its branch is dropped
  • MIPROv2 new API: uses auto="medium" run sizing; removed num_candidates/num_batches, eval_kwargs, and the deprecated requires_permission_to_run arguments
  • COPRO: passes prompt_model=teacher_lm (its actual API) instead of teacher_settings, which COPRO silently ignored
  • ChainOfThoughtWithHint: dspy.ChainOfThoughtWithHint was 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 field
  • Evaluate: Evaluate(...)() now returns an EvaluationResult object, so scores are read via .score
  • Google models: use the gemini/ LiteLLM prefix (google/ is not a valid LiteLLM provider route)
  • New: GEPA optimizer — DSPy 3.x's reflective prompt-evolution optimizer. The selected metric is wrapped to GEPA's feedback-metric contract (extra pred_name/pred_trace args, returns score + textual feedback), with the teacher model used as the reflection LM and auto="light" run sizing

interface.py

  • Removed MIPRO from the optimizer dropdown, added GEPA, and updated the help text

Testing

Verified against DSPy 3.2.1 with a dummy LM (no API keys):

  • ✅ Custom signature creation with field descriptions
  • ✅ All three modules (Predict, ChainOfThought, ChainOfThoughtWithHint incl. hint injection)
  • ✅ Full compile_program run with BootstrapFewShot + Exact Match: baseline eval → compile → eval → program save → example usage with prompt-history extraction
  • ✅ Full compile_program run with GEPA + Exact Match end-to-end
  • py_compile passes for core.py and interface.py

https://claude.ai/code/session_01LNCkRPkq52iz9gCgDnEpLH

claude added 2 commits June 5, 2026 21:18
- 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
@hammer-mt hammer-mt changed the title Upgrade to DSPy 3.x (latest: 3.2.1) Upgrade to DSPy 3.x (latest: 3.2.1) and add GEPA optimizer Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants