pydantic-ai icon indicating copy to clipboard operation
pydantic-ai copied to clipboard

Stricter docstring usage

Open samuelcolvin opened this issue 1 year ago • 1 comments

We should support explicitly setting the format to use, and raising a warning/error if not all parameters are documented set either on the decorator or on Agent __init__.

samuelcolvin avatar Nov 18 '24 11:11 samuelcolvin

Currently we extract descriptions of individual parameters from the docstring by inferring the format of the docstring, then using griffe to pass the docstring.

It would be easy to think you're documenting each parameter, but actually use the wrong format, and it would behave wrongly silently.

We should add two kwargs to the tool decorator, and Tool dataclass:

  • docstring_format: Literal['google', 'numpy', 'sphinx', 'auto'] = 'auto'
  • require_parameter_descriptions: bool = False

samuelcolvin avatar Dec 06 '24 19:12 samuelcolvin