Using #Preview with a PartialyGenerated model

I have an app that streams in data from the Foundation Model and I have a card that shows one of the outputs. I want my card to accept a partially generated model but I keep getting a nonsensical error.

The error I get on line 59 is:

Cannot convert value of type 'FrostDate.VegetableSuggestion.PartiallyGenerated' (aka 'FrostDate.VegetableSuggestion') to expected argument type 'FrostDate.VegetableSuggestion.PartiallyGenerated'

Here is my card with preview:

import SwiftUI
import FoundationModels

struct VegetableSuggestionCard: View {
    let vegetableSuggestion: VegetableSuggestion.PartiallyGenerated
    
    init(vegetableSuggestion: VegetableSuggestion.PartiallyGenerated) {
        self.vegetableSuggestion = vegetableSuggestion
    }
    
    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            if let name = vegetableSuggestion.vegetableName {
                Text(name)
                    .font(.headline)
                    .frame(maxWidth: .infinity, alignment: .leading)
            }
            if let startIndoors = vegetableSuggestion.startSeedsIndoors {
                Text("Start indoors: \(startIndoors)")
                    .frame(maxWidth: .infinity, alignment: .leading)
            }
            if let startOutdoors = vegetableSuggestion.startSeedsOutdoors {
                Text("Start outdoors: \(startOutdoors)")
                    .frame(maxWidth: .infinity, alignment: .leading)
            }
            if let transplant = vegetableSuggestion.transplantSeedlingsOutdoors {
                Text("Transplant: \(transplant)")
                    .frame(maxWidth: .infinity, alignment: .leading)
            }
            if let tips = vegetableSuggestion.tips {
                Text("Tips: \(tips)")
                    .foregroundStyle(.secondary)
                    .frame(maxWidth: .infinity, alignment: .leading)
            }
        }
        .padding(16)
        .frame(maxWidth: .infinity, alignment: .leading)
        .background(
            RoundedRectangle(cornerRadius: 16, style: .continuous)
                .fill(.background)
                .overlay(
                    RoundedRectangle(cornerRadius: 16, style: .continuous)
                        .strokeBorder(.quaternary, lineWidth: 1)
                )
                .shadow(color: Color.black.opacity(0.05), radius: 6, x: 0, y: 2)
        )
    }
}

#Preview("Vegetable Suggestion Card") {
    let sample = VegetableSuggestion.PartiallyGenerated(
        vegetableName: "Tomato",
        startSeedsIndoors: "6–8 weeks before last frost",
        startSeedsOutdoors: "After last frost when soil is warm",
        transplantSeedlingsOutdoors: "1–2 weeks after last frost",
        tips: "Harden off seedlings; provide full sun and consistent moisture."
    )

    VegetableSuggestionCard(vegetableSuggestion: sample)
        .padding()
        .previewLayout(.sizeThatFits)
}

Oy, after I posted I figured out my own answer (I as smarter than ChatGPT).

The key is to use your type and use the .asPartiallyGenerated() method to get a PartiallyGenerated version. Hope this helps someone else.

#Preview("Vegetable Suggestion Card") {
    let sample = VegetableSuggestion(
        vegetableName: "Tomato",
        startSeedsIndoors: "6–8 weeks before last frost",
        startSeedsOutdoors: "After last frost when soil is warm",
        transplantSeedlingsOutdoors: "1–2 weeks after last frost",
        tips: "Harden off seedlings; provide full sun and consistent moisture."
    )

    VegetableSuggestionCard(vegetableSuggestion: sample.asPartiallyGenerated())
        .padding()
}
Using #Preview with a PartialyGenerated model
 
 
Q