You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agents.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -467,6 +467,7 @@ This structure allows you to configure common parameters that influence the mode
467
467
`timeout`, and more.
468
468
469
469
There are two ways to apply these settings:
470
+
470
471
1. Passing to `run{_sync,_stream}` functions via the `model_settings` argument. This allows for fine-tuning on a per-request basis.
471
472
2. Setting during [`Agent`][pydantic_ai.agent.Agent] initialization via the `model_settings` argument. These settings will be applied by default to all subsequent run calls using said agent. However, `model_settings` provided during a specific run call will override the agent's default settings.
Raising `ModelRetry` also generates a `RetryPromptPart` containing the exception message, which is sent back to the LLM to guide its next attempt. Both `ValidationError` and `ModelRetry` respect the `retries` setting configured on the `Tool` or `Agent`.
723
723
724
-
## Use LangChain Tools {#langchain-tools}
724
+
## Third-Party Tools
725
725
726
-
If you'd like to use a tool from LangChain's [community tool library](https://python.langchain.com/docs/integrations/tools/) with PydanticAI, you can use the `pydancic_ai.ext.langchain.tool_from_langchain` convenience method. Note that PydanticAI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the LangChain tool, and up to the LangChain tool to raise an error if the arguments are invalid.
726
+
### MCP Tools {#mcp-tools}
727
727
728
-
Here is how you can use it to augment model responses using a LangChain web search tool. This tool will need you to install the `langchain-community` and `duckduckgo-search` dependencies to work properly.
728
+
See the [MCP Client](./mcp/client.md) documentation for how to use MCP servers with Pydantic AI.
729
+
730
+
### LangChain Tools {#langchain-tools}
731
+
732
+
If you'd like to use a tool from LangChain's [community tool library](https://python.langchain.com/docs/integrations/tools/) with Pydantic AI, you can use the `pydancic_ai.ext.langchain.tool_from_langchain` convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the LangChain tool, and up to the LangChain tool to raise an error if the arguments are invalid.
733
+
734
+
You will need to install the `langchain-community` package and any others required by the tool in question.
735
+
736
+
Here is how you can use the LangChain `DuckDuckGoSearchRun` tool, which requires the `duckduckgo-search` package:
729
737
730
738
```python {test="skip"}
731
739
from langchain_community.tools import DuckDuckGoSearchRun
result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (2)!
752
+
result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (1)!
745
753
print(result.output)
746
754
#> Elden Ring Nightreign is planned to be released on May 30, 2025.
747
755
```
748
756
757
+
1. The release date of this game is the 30th of May 2025, which is after the knowledge cutoff for Gemini 2.0 (August 2024).
758
+
759
+
### ACI.dev Tools {#aci-tools}
760
+
761
+
If you'd like to use a tool from the [ACI.dev tool library](https://www.aci.dev/tools) with Pydantic AI, you can use the `pydancic_ai.ext.aci.tool_from_aci` convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the ACI tool, and up to the ACI tool to raise an error if the arguments are invalid.
762
+
763
+
You will need to install the `aci-sdk` package, set your ACI API key in the `ACI_API_KEY` environment variable, and pass your ACI "linked account owner ID" to the function.
764
+
765
+
Here is how you can use the ACI.dev `TAVILY__SEARCH` tool:
* If False, the URL is sent directly to the model and no download is performed.
100
100
"""
101
101
102
+
vendor_metadata: dict[str, Any] |None=None
103
+
"""Vendor-specific metadata for the file.
104
+
105
+
Supported by:
106
+
- `GoogleModel`: `VideoUrl.vendor_metadata` is used as `video_metadata`: https://ai.google.dev/gemini-api/docs/video-understanding#customize-video-processing
107
+
"""
108
+
102
109
@property
103
110
@abstractmethod
104
111
defmedia_type(self) ->str:
@@ -175,13 +182,25 @@ class AudioUrl(FileUrl):
175
182
176
183
@property
177
184
defmedia_type(self) ->AudioMediaType:
178
-
"""Return the media type of the audio file, based on the url."""
185
+
"""Return the media type of the audio file, based on the url.
- `GoogleModel`: `BinaryContent.vendor_metadata` is used as `video_metadata`: https://ai.google.dev/gemini-api/docs/video-understanding#customize-video-processing
290
+
"""
291
+
266
292
kind: Literal['binary'] ='binary'
267
293
"""Type identifier, this is available on all parts as a discriminator."""
0 commit comments