LeapFunction definitions on the Conversation, run generation as usual, and the modelβs tool-call tokens come back as MessageResponse.functionCalls.
Vision and audio-capable models require companion files. Bundles embed these references; GGUF checkpoints expect siblings such as
mmproj-*.gguf (vision) and audio decoder/tokenizer files. When detected, you can attach ChatMessageContent.image / .audio parts to your tool responses as well as user messages.Register functions on the conversation
Conversation.registerFunction takes a LeapFunction instance describing name, parameters, and purpose.
- Swift (iOS / macOS)
- Kotlin (all platforms)
The Kotlin
LeapFunction / LeapFunctionParameter constructors carry @ObjCName annotations on description:, so the Swift labels are functionDescription: and parameterDescription:. LeapFunctionParameterβs optional parameter has no Swift default β pass optional: false for required parameters.The Kotlin parameter type classes are named with a
Leap prefix (LeapStr, LeapNum, LeapInt, LeapBool, LeapArr, LeapObj, LeapNull) to avoid collisions with Kotlinβs built-in String, Number, Int, Boolean, etc. The Swift bindings expose the same names β there are no separate .string(...) / .number(...) aliases; SKIE preserves the Kotlin nested-class names.Handle the response
Function calls arrive as theMessageResponse.FunctionCalls variant on both platforms, wrapping a list of LeapFunctionCall payloads.
- Swift (iOS / macOS)
- Kotlin (all platforms)
LeapFunctionCall is a Kotlin data class bridged into Swift. arguments is a Kotlin Map<String, Any?> exposed as Swift [String: Any] (the ObjC bridge collapses Any? to non-optional id):Sending tool results back
Append the toolβs output as atool-role message and continue the conversation. Both platforms use the same shape β see also Quick Start β Add tool results back to history.
- Swift (iOS / macOS)
- Kotlin (all platforms)
generateResponse(...) on the new conversation to get the modelβs tool-aware reply.
LeapFunction
- Swift (iOS / macOS)
- Kotlin (all platforms)
Both types are Kotlin
data classes bridged into Swift. @ObjCName annotations rename the description parameter on the Swift inits to functionDescription: / parameterDescription:.Parameter types
LeapFunctionParameterType is translated into JSON Schema for the model. The same primitive set is exposed on both platforms.
- Swift (iOS / macOS)
- Kotlin (all platforms)
LeapFunctionParameterType is a Kotlin sealed class. SKIE generates an onEnum(of:)-compatible enum view, but the constructors you use to build instances keep the Kotlin nested-class names β there is no .string(...) / .number(...) alias.LeapStr/LeapNum/LeapIntacceptenumValuesto constrain valid values.LeapArrhasitemTypedescribing the element type.LeapObjhasproperties: [String: LeapFunctionParameterType]andrequired: [String].- The nested
descriptionis overridden when the type is used directly asLeapFunctionParameter.type; itβs only consulted when the type is used insideLeapArr.itemTypeorLeapObj.properties.
Example: array + enum parameters
- Swift (iOS / macOS)
- Kotlin (all platforms)
Function call parser
Different models emit tool-call tokens in different shapes. The parser translates those tokens intoLeapFunctionCall values. The default LFMFunctionCallParser handles Liquid Foundation Model (LFM2) Pythonic-style control tokens (<|tool_call_start|> ... <|tool_call_end|>). For Qwen3 and other models using the Hermes function-calling format, use HermesFunctionCallParser.
- Swift (iOS / macOS)
- Kotlin (all platforms)
null / nil as the parser to disable tool-call parsing entirely β the raw tool-call text is then surfaced as ordinary Chunks.