Tool for reliable LLM tool calling with complex JSON schemas
Top 44.2% on sourcepulse
trustcall is a Python library designed to enhance the reliability and efficiency of LLM tool calling, particularly for complex JSON schema generation and updates. It addresses common LLM failures in producing structured output by prompting LLMs to generate JSON Patch operations for iterative correction, making it ideal for developers building robust LLM-powered applications.
How It Works
trustcall leverages LangGraph to manage a stateful, iterative process. When an LLM is asked to generate or update structured data, trustcall first prompts it to produce the output directly. If validation errors occur (e.g., with Pydantic models), it re-prompts the LLM to generate JSON Patch operations to correct the specific errors. This "patch-don't-post" approach is more resilient and cost-effective than regenerating the entire output. It also supports updating existing data structures by applying patches to provided schemas.
Quick Start & Requirements
pip install trustcall
Highlighted Details
Maintenance & Community
The project appears to be actively maintained by hinthornw. Further community engagement details (e.g., Discord, Slack) are not explicitly mentioned in the README.
Licensing & Compatibility
The README does not explicitly state a license. Compatibility for commercial use or closed-source linking would require clarification on the licensing terms.
Limitations & Caveats
The README does not detail specific limitations, unsupported platforms, or known bugs. The effectiveness of the patch-based correction relies on the LLM's ability to accurately generate valid JSON Patches. Evaluation benchmarks are available but require additional dependencies and API keys.
2 weeks ago
1 week