Creating Custom Functions
Basic Function
Any Python function can become a tool:Convert to Tool
Use with Agent
Function Design
Type Hints
Always use type hints:Docstrings
Write clear docstrings:Examples
Calculator Tool
Time Tool
Weather Tool
Best Practices
Function Design
- ✅ Clear names - Use descriptive function names
- ✅ Type hints - Always include type hints
- ✅ Docstrings - Explain what the function does
- ✅ Error handling - Return helpful error messages
- ✅ Idempotent - Safe to call multiple times when possible
Parameter Design
- ✅ Simple types - Use str, int, float, bool
- ✅ Clear names - Descriptive parameter names
- ✅ Optional parameters - Use Optional for optional params
- ✅ Defaults - Provide sensible defaults
Next Steps
- Function Calling → - Understand how it works
- REST API Tools → - Connect to APIs
- Toolkits → - Organize your tools
- Python SDK → - Implementation details

