This commit fixes the chat template to properly handle function calls by: 1. Using safe dictionary access with .get() 2. Converting function arguments to JSON with |tojson filter 3. Adding better empty content handling Fixes #860