What is Vaul?
Vaul is a specialized toolkit that addresses the challenges of creating and managing tool calls for AI systems. It serves as a bridge between your application’s functionality and LLM capabilities, enabling seamless integration of custom tools that extend what your AI can do. Key aspects of Vaul include:- Easy Tool Call Definition: Define tool calls using simple decorators
- Automatic Schema Generation: Generate OpenAPI schemas from function signatures
- Built-in Validation: Ensure input data integrity using Pydantic validation
- Seamless AI Integration: Integrate tool calls with AI systems like OpenAI’s GPT
- Toolkit Management: Organize and manage collections of tools with the Toolkit class
- Documentation Generation: Create beautiful markdown tables of your tools with
to_markdown()to keep system prompts in sync with your toolkit - Customizable: Define custom actions and manage them with ease
Components
Tool Call Decorator
The core of Vaul is the@tool_call decorator, which transforms regular Python functions into tool calls that can be used by AI systems. This decorator:
- Extracts function signature information
- Generates OpenAPI schemas
- Adds validation capabilities
- Provides methods for interacting with AI responses
Toolkit Class
TheToolkit class serves as a container for managing collections of tool calls. It provides methods for:
- Adding individual tools or multiple tools at once
- Generating schemas for all registered tools
- Running specific tools by name
- Creating documentation for the available tools
- Managing tool configurations centrally
Documentation Generator
Vaul includes a documentation generator that creates markdown tables describing the available tools. This feature helps maintain consistency between your code and AI system prompts, ensuring that:- System prompts accurately reflect available tools
- Tool descriptions match their implementation
- AI systems have clear guidance on when to use each tool
Benefits
Using Vaul in your TextLayer Core projects offers several advantages:Developer Experience
- Simplified API: Clean, decorator-based approach to defining tools
- Reduced Boilerplate: Automatic schema generation and validation
- Type Safety: Leverages Python type hints for better code quality
- Documentation: Automatic generation of tool documentation
AI Integration
- Seamless Integration: Works directly with OpenAI and other LLM providers
- Consistent Interface: Standardized approach to tool definition
- Validation: Ensures that inputs meet expected formats
- Error Handling: Graceful handling of invalid inputs or execution errors
Maintainability
- Centralized Management: Organize all tools in a single toolkit
- Documentation Sync: Keep system prompts in sync with available tools
- Extensibility: Easily add new tools as requirements evolve
- Testing: Simplified testing of tool functionality
Installation
To install Vaul, you can usepip:
Basic Usage
Defining Tool Calls
Vaul allows you to define tool calls using simple decorators. Here is an example of how to define a function that can be utilized by an AI system:Managing Tool Calls with Toolkit
Vaul provides aToolkit class that helps you organize and manage multiple tool calls efficiently:
Tool Documentation Format
When creating tool calls, you can add structured documentation to your function docstrings that will be extracted by theto_markdown method. This makes it easy to generate clear documentation tables for users.
The docstring format supports the following special tags:
Desc:- A detailed description of what the tool doesUsage:- Guidance on when to use this tool
Desc: tag is provided, the first line of the docstring will be used as the description.
You can then generate a nicely formatted markdown table of all your tools using:
Keeping System Prompts in Sync with Toolkits
One of the most powerful features ofto_markdown is its ability to help maintain consistency between your code and AI system prompts. As your toolkit evolves with new tools or updated functionality, you can dynamically generate up-to-date documentation to include in your system prompts.
For example, when working with LLM agents that need to know about available tools:
- Your system prompt always contains the latest tools information
- The AI has accurate guidance on when to use each tool
- The tool descriptions in the prompt match the actual implementation
- When you add, remove or modify tools, the system prompt updates automatically
Interacting with OpenAI
You can integrate Vaul with OpenAI to create, monitor, and deploy tool calls. Here is an example that demonstrates how to use a tool call with OpenAI’s GPT-3.5-turbo:Complex Example: JIRA Integration
Let’s take a look at how you might handle a more complex application, such as one that integrates multiple potential tool calls:Integration with TextLayer Core
Vaul integrates seamlessly with TextLayer Core, providing several key benefits:Extending AI Capabilities
Vaul allows developers to extend the capabilities of their AI applications by creating custom tools that can:- Access external APIs and services
- Perform specialized calculations or data processing
- Interact with databases or file systems
- Execute business logic based on user requests
Standardized Tool Development
By using Vaul, TextLayer Core provides a standardized approach to tool development, ensuring:- Consistent patterns across all tools
- Proper validation and error handling
- Clear documentation for both developers and AI systems
- Simplified integration with LLM providers
Enhanced Observability
When combined with Langfuse (part of the FLEX Stack), Vaul-based tools provide enhanced observability:- Track tool usage and performance
- Monitor success rates and error patterns
- Analyze which tools are most frequently used
- Identify opportunities for improvement