flutter_gemma_rag_sqlite 1.1.0 copy "flutter_gemma_rag_sqlite: ^1.1.0" to clipboard
flutter_gemma_rag_sqlite: ^1.1.0 copied to clipboard

SQLite vector search (sqlite-vec) on-device RAG vector store for flutter_gemma. Opt-in package; implements flutter_gemma's VectorStoreRepository.

example/README.md

flutter_gemma_rag_sqlite example #

flutter_gemma_rag_sqlite is an opt-in vector store for flutter_gemma that works on every platform: in-SQLite sqlite-vec/vec0 KNN on native (sqlite3 via dart:ffi) and web (package:sqlite3/wasm + a custom sqlite3.wasm). Register it once at startup, then use the unchanged RAG API on FlutterGemmaPlugin.instance.

import 'package:flutter/widgets.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter_gemma/flutter_gemma.dart';
import 'package:flutter_gemma_rag_sqlite/flutter_gemma_rag_sqlite.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Native uses SqliteVectorStore; web uses WebSqliteVectorStore.
  await FlutterGemma.initialize(
    vectorStore: kIsWeb ? WebSqliteVectorStore() : SqliteVectorStore(),
  );

  final gemma = FlutterGemmaPlugin.instance;

  await gemma.initializeVectorStore('rag_store.db');

  // Add a document with a pre-computed embedding (e.g. from
  // flutter_gemma_embeddings).
  await gemma.addDocumentWithEmbedding(
    id: 'doc-1',
    content: 'Gemma runs fully on-device.',
    embedding: List<double>.filled(768, 0.0), // your real embedding here
    metadata: '{"lang":"en"}',
  );

  final hits = await gemma.searchSimilar(query: 'on-device LLM', topK: 5);
  for (final h in hits) {
    print('${h.id}: ${h.content} (score ${h.similarity})');
  }
}

On web, the custom sqlite3.wasm (with sqlite-vec linked in) is served as a web asset — no CDN <script> is needed; see the package README for the wasm wiring. Native platforms need no setup (sqlite3 bundles its own library; the vec0 extension is bundled via the package's Native Assets hook). A full runnable app wiring every engine and RAG store together lives in the flutter_gemma example.

0
likes
160
points
515
downloads

Documentation

API reference

Publisher

verified publishersashadenisov.dev

Weekly Downloads

SQLite vector search (sqlite-vec) on-device RAG vector store for flutter_gemma. Opt-in package; implements flutter_gemma's VectorStoreRepository.

Homepage
Repository (GitHub)
View/report issues

Topics

#rag #sqlite #vector-search #embeddings #web

License

MIT (license)

Dependencies

code_assets, flutter, flutter_gemma, hooks, sqlite3

More

Packages that depend on flutter_gemma_rag_sqlite