SDK Reference
SDK Local Functions
How to use local functions with the xpander AI SDK
Local functions allow your AI agents to interact with your local system through predefined functions. This enables capabilities like file operations while maintaining security through controlled access.
Defining Local Tools
First, define your local tools with their specifications:
Implementation Examples
File Operation Functions
Here are the core file operation functions used by the local tools:
Security Considerations
- Path Validation: All file operations are restricted to the current working directory
- Format Validation: Only allowed file formats (json/txt/csv/xml) are processed
- Error Handling: Comprehensive error handling for all file operations
- Input Sanitization: All inputs are validated before processing
Best Practices
- Always validate file paths using
is_within_current_directory()
- Handle file format conversions carefully
- Implement proper error handling for all operations
- Use appropriate content type validation
- Keep security considerations in mind when implementing new local functions