isAvailable (GeminiNano.ts)

lumiere · gemini-nano, on-device-llm, android-native-module, capability-detection, ai

eslint-disable @typescript-eslint/no-explicit-any */ * TypeScript wrapper for the GeminiNano native Expo module. At build time the native module is linked automatically by Expo. We use `require` + runtime guard so the app doesn't crash on platforms where the module doesn't exist

/* eslint-disable @typescript-eslint/no-explicit-any */

/**
 * TypeScript wrapper for the GeminiNano native Expo module.
 *
 * At build time the native module is linked automatically by Expo.
 * We use `require` + runtime guard so the app doesn't crash on
 * platforms where the module doesn't exist (iOS, older Android).
 */

interface GeminiNanoNativeModule {
  isAvailable(): boolean
  generateResponse(systemPrompt: string, messages: string): Promise<string>
  startStreaming(systemPrompt: string, messages: string, requestId: string): Promise<void>
  addListener(eventName: string): void
  removeListeners(count: number): void
}

interface StreamingDeltaEvent {
  delta: string
  requestId: string
}

interface StreamingCompleteEvent {
  requestId: string
}

interface StreamingErrorEvent {
  e

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key