From d56b673c72018c066426f6fb9eecbfeca4c20ee1 Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Wed, 26 Feb 2025 19:51:30 +0530 Subject: [PATCH] add: automatic patching for an evaluation metric --- weave/integrations/dspy/dspy_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/weave/integrations/dspy/dspy_utils.py b/weave/integrations/dspy/dspy_utils.py index 6f78bf36004d..22d59699724b 100644 --- a/weave/integrations/dspy/dspy_utils.py +++ b/weave/integrations/dspy/dspy_utils.py @@ -70,7 +70,14 @@ def dspy_postprocess_inputs(inputs: dict[str, Any]) -> dict[str, Any]: dictified_inputs_self = serialize_dspy_objects(dictified_inputs_self) if isinstance(inputs["self"], Evaluate): - dictified_inputs_self["devset"] = inputs["self"].devset + if hasattr(inputs["self"], "devset"): + dictified_inputs_self["devset"] = [ + serialize_dspy_objects(example) for example in inputs["self"].devset + ] + + # TODO: This is a hack to make the metric a weave op. Should we do this? Need to ask Ayush tomorrow. + if hasattr(inputs["self"], "metric"): + inputs["self"].metric = weave.op(inputs["self"].metric) inputs["self"] = dictified_inputs_self