mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Refactor DashBot
This commit is contained in:
26
lib/dashbot/repository/chat_remote_repository.dart
Normal file
26
lib/dashbot/repository/chat_remote_repository.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
/// Repository for talking to the GenAI layer.
|
||||
abstract class ChatRemoteRepository {
|
||||
/// Execute a non-streaming chat completion.
|
||||
Future<String?> sendChat({required AIRequestModel request});
|
||||
}
|
||||
|
||||
class ChatRemoteRepositoryImpl implements ChatRemoteRepository {
|
||||
ChatRemoteRepositoryImpl();
|
||||
|
||||
@override
|
||||
Future<String?> sendChat({required AIRequestModel request}) async {
|
||||
final result = await executeGenAIRequest(request);
|
||||
if (result == null || result.isEmpty) return null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for the repository
|
||||
final chatRepositoryProvider = Provider<ChatRemoteRepository>((ref) {
|
||||
return ChatRemoteRepositoryImpl();
|
||||
});
|
||||
1
lib/dashbot/repository/repository.dart
Normal file
1
lib/dashbot/repository/repository.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'chat_remote_repository.dart';
|
||||
Reference in New Issue
Block a user