Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Automatically copy over "description" from pydantic field to dspy field

Thomas D Ahle259d6b03aa6e
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