@react-native-leap/ai
v0.1.0
Published
Vercel AI SDK provider for react-native-leap — on-device LFM models via streamText/generateText/generateObject.
Downloads
83
Readme
@react-native-leap/ai
Vercel AI SDK provider for react-native-leap — run streamText / generateText / generateObject against on-device LFM models (LanguageModel spec v4, AI SDK v6+).
npm install @react-native-leap/ai react-native-leap aiimport { streamText, generateObject } from "ai";
import { leap } from "@react-native-leap/ai";
import { z } from "zod";
const result = streamText({
model: leap("LFM2.5-1.2B-Instruct"),
prompt: "Write a haiku about running AI on a phone.",
});
for await (const chunk of result.textStream) console.log(chunk);
const { object } = await generateObject({
model: leap("LFM2.5-350M"),
schema: z.object({ vendor: z.string(), total: z.number() }),
prompt: "Extract: coffee $4.50 at Blue Bottle",
});- The model downloads/loads lazily on first use (
onLoadProgressin settings), or wrap an already-loaded model:leap.fromModel(model)(pairs withuseLeapModel). - Tool calling works with the AI SDK's own loop (
tools+stopWhen); reasoning models streamreasoningparts. - Each call rebuilds the conversation from the prompt — LEAP's KV cache (on by default here) makes repeated prefixes cheap, surfaced as
usage.inputTokens.cacheRead. - React Native needs the AI SDK's usual runtime polyfills (
ReadableStream,TextEncoder/TextDecoder,structuredClone) — see the AI SDK React Native guide.
MIT · unofficial community project, not affiliated with Liquid AI.
