The framework defines the tool interface through the Pydantic model, which not only supports OpenAI native function calls, but also creates a unique ToolMessage mechanism to guarantee the ability of non-OpenAI model tool calls. When LLM generates a tool call request, the system automatically captures the structured message and executes the corresponding Python function, and is also fault-tolerant in handling incorrectly formatted JSON output. This design enables developers to uniformly extend external capabilities such as database queries, API calls, and other complex operations for local or cloud-based LLMs.
This answer comes from the articleLangroid: Easily Navigating Large Language Models with Multi-Intelligent Body ProgrammingThe