edge_veda library

Edge Veda SDK - On-device LLM inference for Flutter

Example usage:

import 'package:edge_veda/edge_veda.dart';

final edgeVeda = EdgeVeda();
await edgeVeda.init(EdgeVedaConfig(modelPath: '/path/to/model.gguf'));
final response = await edgeVeda.generate('Hello, world!');
print(response.text);
await edgeVeda.dispose();

Features

  • On-device LLM inference with llama.cpp and Metal acceleration
  • Model download with progress tracking and caching
  • Memory-safe operations with configurable limits
  • Zero server costs and 100% offline operation

Model Management

final modelManager = ModelManager();

// Download a pre-configured model
final modelPath = await modelManager.downloadModel(
  ModelRegistry.llama32_1b,
);

// Monitor download progress
modelManager.downloadProgress.listen((progress) {
  print('Progress: ${progress.progressPercent}%');
});

// Check downloaded models
final models = await modelManager.getDownloadedModels();
print('Downloaded: $models');

Memory Monitoring

// Check memory usage
final stats = await edgeVeda.getMemoryStats();
print('Memory: ${(stats.usagePercent * 100).toStringAsFixed(1)}%');

// Quick pressure check
if (await edgeVeda.isMemoryPressure()) {
  print('High memory usage!');
}

Classes

CancelToken
Token for cancelling ongoing operations (downloads, generation)
DownloadProgress
Model download progress information
EdgeVeda
Main Edge Veda SDK class for on-device AI inference
EdgeVedaConfig
Configuration for initializing Edge Veda SDK
GenerateOptions
Options for text generation
GenerateResponse
Response from text generation
MemoryPressureEvent
Memory pressure event from native layer
MemoryStats
Memory usage statistics from native layer
ModelInfo
Model information
ModelManager
Manages model downloads, caching, and verification
ModelRegistry
Pre-configured model registry with popular models
TokenChunk
Token chunk in a streaming response

Exceptions / Errors

ChecksumException
Thrown when checksum verification fails
ConfigurationException
Thrown when invalid configuration is provided
DownloadException
Thrown when model download fails
EdgeVedaException
Base exception class for Edge Veda errors
EdgeVedaGenericException
Generic exception for unknown native errors
GenerationException
Thrown when text generation fails
InitializationException
Thrown when SDK initialization fails
MemoryException
Thrown when memory limit is exceeded
ModelLoadException
Thrown when model loading fails
ModelValidationException
Thrown when model file fails validation (checksum mismatch, corrupted file)