Skip to content

Commit 368b2e1

Browse files
authored
Update Function tools docs with usage of docstring_format and require_parameter_descriptions (#776)
1 parent 985f186 commit 368b2e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/tools.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Function parameters are extracted from the function signature, and all parameter
234234

235235
Even better, PydanticAI extracts the docstring from functions and (thanks to [griffe](https://mkdocstrings.github.io/griffe/)) extracts parameter descriptions from the docstring and adds them to the schema.
236236

237-
[Griffe supports](https://mkdocstrings.github.io/griffe/reference/docstrings/#docstrings) extracting parameter descriptions from `google`, `numpy` and `sphinx` style docstrings, and PydanticAI will infer the format to use based on the docstring. We plan to add support in the future to explicitly set the style to use, and warn/error if not all parameters are documented; see [#59](https://github.com/pydantic/pydantic-ai/issues/59).
237+
[Griffe supports](https://mkdocstrings.github.io/griffe/reference/docstrings/#docstrings) extracting parameter descriptions from `google`, `numpy`, and `sphinx` style docstrings. PydanticAI will infer the format to use based on the docstring, but you can explicitly set it using [`docstring_format`][pydantic_ai.tools.DocstringFormat]. You can also enforce parameter requirements by setting `require_parameter_descriptions=True`. This will raise a [`UserError`][pydantic_ai.exceptions.UserError] if a parameter description is missing.
238238

239239
To demonstrate a tool's schema, here we use [`FunctionModel`][pydantic_ai.models.function.FunctionModel] to print the schema a model would receive:
240240

@@ -246,7 +246,7 @@ from pydantic_ai.models.function import AgentInfo, FunctionModel
246246
agent = Agent()
247247

248248

249-
@agent.tool_plain
249+
@agent.tool_plain(docstring_format='google', require_parameter_descriptions=True)
250250
def foobar(a: int, b: str, c: dict[str, list[float]]) -> str:
251251
"""Get me foobar.
252252

0 commit comments

Comments
 (0)