From 259d6b03aa6e6d8dafcc7499339acaf665b0a80e Mon Sep 17 00:00:00 2001 From: Thomas D Ahle Date: Thu, 14 Mar 2024 13:25:45 -0700 Subject: [PATCH] Automatically copy over "description" from pydantic field to dspy field --- dspy/signatures/field.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dspy/signatures/field.py b/dspy/signatures/field.py index 4e3271477..4e8acd687 100644 --- a/dspy/signatures/field.py +++ b/dspy/signatures/field.py @@ -19,6 +19,9 @@ def move_kwargs(**kwargs): json_schema_extra[k] = v else: pydantic_kwargs[k] = v + # Also copy over the pydantic "description" if no dspy "desc" is given. + if "description" in kwargs and "desc" not in json_schema_extra: + json_schema_extra["desc"] = kwargs["description"] pydantic_kwargs["json_schema_extra"] = json_schema_extra return pydantic_kwargs