Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Refactor ReflectiveExample TypedDict documentation (#9133)

Lakshya A Agrawal31c50624ead0
diff --git a/dspy/teleprompt/gepa/gepa_utils.py b/dspy/teleprompt/gepa/gepa_utils.py
index f430b599e..6f4fa09c2 100644
--- a/dspy/teleprompt/gepa/gepa_utils.py
+++ b/dspy/teleprompt/gepa/gepa_utils.py
@@ -33,17 +33,20 @@ class LoggerAdapter:
DSPyTrace = list[tuple[Any, dict[str, Any], Prediction]]
-
-class ReflectiveExample(TypedDict):
- """
- Structure of individual examples in the reflective dataset.
-
- Each example contains the predictor inputs, generated outputs, and feedback from evaluation.
- """
-
- Inputs: dict[str, Any] # Predictor inputs (may include str, dspy.Image, etc.)
- Generated_Outputs: dict[str, Any] | str # Success: dict with output fields, Failure: error message string
- Feedback: str # Always a string - from metric function or parsing error message
+ReflectiveExample = TypedDict(
+ "ReflectiveExample",
+ {
+ "Inputs": dict[str, Any],
+ "Generated Outputs": dict[str, Any] | str,
+ "Feedback": str,
+ },
+)
+
+ReflectiveExample.__doc__ = """
+Structure of individual examples in the reflective dataset.
+
+Each example contains the predictor inputs, generated outputs, and feedback from evaluation.
+"""
class ScoreWithFeedback(Prediction):