feat: set up Flutter project with drift database, Riverpod providers, and LLM service layer
- Configure dependencies: drift 2.32.x, flutter_riverpod 3.3.1, fl_chart 1.2.x, flutter_local_notifications 21.x, local_auth 3.x, and supporting packages - Drop riverpod_generator (incompatible analyzer version with drift_dev 2.32.x); convert all providers to manual Riverpod 3.x API using Notifier<T> and typed families - Define drift schema: MoodEntries, Activities, EntryActivities, Tags, EntryTags, LlmInsights, UserSettings with four DAOs (mood, activity, insight, settings) - Add LLM service abstraction (LlmService) and MediaPipe implementation - Fix SettingsDao.delete → deleteByKey to avoid shadowing drift's inherited delete method
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
abstract class LlmService {
|
||||
Future<void> initialise();
|
||||
Stream<String> generateStream(String prompt);
|
||||
void dispose();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter_mediapipe_chat/flutter_mediapipe_chat.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'llm_service.dart';
|
||||
|
||||
class MediapipeLlmService implements LlmService {
|
||||
final _chat = FlutterMediapipeChat();
|
||||
bool _initialised = false;
|
||||
|
||||
static const _modelFileName = 'gemma-2b-it-cpu-int4.bin';
|
||||
|
||||
@override
|
||||
Future<void> initialise() async {
|
||||
if (_initialised) return;
|
||||
final dir = await getApplicationSupportDirectory();
|
||||
final modelPath = p.join(dir.path, _modelFileName);
|
||||
await _chat.loadModel(ModelConfig(path: modelPath));
|
||||
_initialised = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<String> generateStream(String prompt) {
|
||||
return _chat.generateResponseAsync(prompt);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_initialised = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user