TealConverse

@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
class TealConverse

Class for model loading and prediction

  • Declaration

    Swift

    let model: MLModel
  • URL of model assuming it was installed in the same bundle as this class

    Declaration

    Swift

    class var urlOfModelInThisBundle: URL { get }
  • Construct TealConverse instance with an existing MLModel object.

    Usually the application does not use this initializer unless it makes a subclass of TealConverse. Such application may want to use MLModel(contentsOfURL:configuration:) and TealConverse.urlOfModelInThisBundle to create a MLModel object to pass-in.

    Declaration

    Swift

    init(model: MLModel)

    Parameters

    model

    MLModel object

  • Construct TealConverse instance by automatically loading the model from the app’s bundle.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(configuration:﹚ instead and handle errors appropriately.")
    convenience init()
  • Construct a model with configuration

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    @available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
    convenience init(configuration: MLModelConfiguration) throws

    Parameters

    configuration

    the desired model configuration

  • Construct TealConverse instance with explicit path to mlmodelc file

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    convenience init(contentsOf modelURL: URL) throws

    Parameters

    modelURL

    the file url of the model

  • Construct a model with URL of the .mlmodelc directory and configuration

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    @available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
    convenience init(contentsOf modelURL: URL, configuration: MLModelConfiguration) throws

    Parameters

    modelURL

    the file url of the model

    configuration

    the desired model configuration

  • Construct TealConverse instance asynchronously with optional configuration.

    Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread.

    Declaration

    Swift

    @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
    class func load(configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<TealConverse, Error>) -> Void)

    Parameters

    configuration

    the desired model configuration

    handler

    the completion handler to be called when the model loading completes successfully or unsuccessfully

  • Construct TealConverse instance asynchronously with URL of the .mlmodelc directory with optional configuration.

    Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread.

    Declaration

    Swift

    @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
    class func load(contentsOf modelURL: URL, configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<TealConverse, Error>) -> Void)

    Parameters

    modelURL

    the URL to the model

    configuration

    the desired model configuration

    handler

    the completion handler to be called when the model loading completes successfully or unsuccessfully

  • Make a prediction using the structured interface

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    func prediction(input: TealConverseInput) throws -> TealConverseOutput

    Parameters

    input

    the input to the prediction as TealConverseInput

    Return Value

    the result of the prediction as TealConverseOutput

  • Make a prediction using the structured interface

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    func prediction(input: TealConverseInput, options: MLPredictionOptions) throws -> TealConverseOutput

    Parameters

    input

    the input to the prediction as TealConverseInput

    options

    prediction options

    Return Value

    the result of the prediction as TealConverseOutput

  • Make a prediction using the convenience interface

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    func prediction(canEscape: String, nearExit: String, nearInput: String, inputActive: String, inputRelevant: String, requiresObject: String, requiresCostume: String, wearingCostume: String, hasObject: String, nearObject: String, allInputsActive: String) throws -> TealConverseOutput

    Return Value

    the result of the prediction as TealConverseOutput

  • Make a batch prediction using the structured interface

    Throws

    an NSError object that describes the problem

    Declaration

    Swift

    @available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
    func predictions(inputs: [TealConverseInput], options: MLPredictionOptions = MLPredictionOptions()) throws -> [TealConverseOutput]

    Parameters

    inputs

    the inputs to the prediction as [TealConverseInput]

    options

    prediction options

    Return Value

    the result of the prediction as [TealConverseOutput]