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
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:
0 commit comments