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

SQLite + HNSW on-device RAG vector store for flutter_gemma (native sqlite3 + web wa-sqlite). 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: native (sqlite3 + HNSW via dart:ffi) and web (wa-sqlite 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, load the wa-sqlite engine from a <script> in web/index.html — see the package README for the SRI-pinned tag setup. Native platforms need no setup (sqlite3 bundles its own library). A full runnable app wiring every engine and RAG store together lives in the flutter_gemma example.

0
likes
160
points
162
downloads

Documentation

API reference

Publisher

verified publishersashadenisov.dev

Weekly Downloads

SQLite + HNSW on-device RAG vector store for flutter_gemma (native sqlite3 + web wa-sqlite). 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

flutter, flutter_gemma, local_hnsw, sqlite3

More

Packages that depend on flutter_gemma_rag_sqlite