Add convenience method to use LangChain community tools

Merged
MA
1y ago
+494-8

References #1831

This does work however the style and approach are very much open for discussion. In particular:

  • this creates a function just so it can be inspected, as part of that it has a very bad mapping from json schema types back to python.
  • the pydantic_ai.tool.Tool class has no base class that describes the desired behaviour.
  • the LangChain BaseTool defines json schemas for the args and similar which could more directly be translated to the pydantic_ai.tool.Tool class.
  • future integrations of this type might benefit from a similar approach.

To make my PR simple I have introduced a minimal change. I think it would be good to discuss a more maintainable and extensible approach.