Contents

ContactResolver

An interface you use to help Foundation models resolve references to the person using the app.

Declaration

protocol ContactResolver : Sendable

Mentioned in

Overview

When a search involves people, the search tool needs to know how to resolve references to “I” or “me” in any conversations. Implement this protocol in a custom type and assign it to the Spotlight search tool you use with your Foundation models session. Your custom type returns a ResolvedContact structure, which contains any information your app uses to refer to the person. For example, fill the structure with name information, email addresses, or phone numbers from the account your app manages.

The following example shows an implementation of this structure and the code you use to assign it to your Spotlight search tool.

struct MyContactResolver: ContactResolver {
    func userIdentity() -> ResolvedContact {
        var contact = ResolvedContact(displayName: "John Appleseed")
        contact.emailAddresses = ["john@example.com"]
        return contact
    }
}

var configuration = SpotlightSearchTool.Configuration()
configuration.contactResolver = MyContactResolver()

Topics

Returning the identity data

See Also

Contact resolution