localLlm function
- @Riverpod(keepAlive: true)
On-device LLM inference (llama.cpp via llama_cpp_dart). null on web
— there's no isolate / dart:io / GGUF runtime in the browser. Also
null when the feature flag EnvConfig.enableLocalLlm is off, which
hides the provider from users while keeping the implementation in the
tree. On native with the flag on, isConfigured() returns false until
the user downloads + activates a model in AI settings, so chat sessions
cleanly skip the local provider when nothing is installed.
Implementation
@Riverpod(keepAlive: true)
LocalLlmDatasource? localLlm(Ref ref) {
if (!EnvConfig.isLocalLlmAvailable) return null;
final ds = LocalLlmDatasource();
ref.onDispose(ds.dispose);
return ds;
}