Package 

Class AIOnDeviceModel

  • All Implemented Interfaces:
    io.getstream.chat.android.ai.ondevice.AILocalModel , java.lang.AutoCloseable

    
    public final class AIOnDeviceModel
     implements AILocalModel, AutoCloseable
                        

    Gemini Nano, the model in Android's AICore, through ML Kit's GenAI Prompt API. It answers without a network connection, and the conversation never leaves the device.

    It runs on devices whose AICore offers Gemini Nano (recent Pixel, Samsung and other flagship phones), not on emulators. The model may need downloading first: status says whether it is Status.Downloadable or Status.Downloading, and download starts it.

    It is a small model, good for short answers and for working with what is in the conversation. Its context holds a few thousand tokens, so the oldest turns of a long conversation are left out.

    val model = AIOnDeviceModel(context)
    if (model.isAvailable()) {
        model.reply(instructions, turns).collect { answer -> show(answer) }
    }
    • Constructor Detail

      • AIOnDeviceModel

        AIOnDeviceModel(Context context, Integer maximumResponseTokens)
        Parameters:
        context - Any context; the application context is kept.
        maximumResponseTokens - The longest answer, in tokens.