refactor: remove streaming functionality from ChatRemoteRepository and add tests

This commit is contained in:
Udhay-Adithya
2025-09-28 17:48:53 +05:30
parent 6311dbbe26
commit b2a346cdce
2 changed files with 163 additions and 12 deletions

View File

@@ -1,13 +1,10 @@
import 'dart:async';
import 'package:apidash_core/apidash_core.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:genai/genai.dart';
/// Repository for talking to the GenAI layer.
abstract class ChatRemoteRepository {
/// Stream a chat completion with the provided AI request.
Stream<String> streamChat({required AIRequestModel request});
/// Execute a non-streaming chat completion.
Future<String?> sendChat({required AIRequestModel request});
}
@@ -15,14 +12,6 @@ abstract class ChatRemoteRepository {
class ChatRemoteRepositoryImpl implements ChatRemoteRepository {
ChatRemoteRepositoryImpl();
@override
Stream<String> streamChat({required AIRequestModel request}) async* {
final stream = await streamGenAIRequest(request);
await for (final chunk in stream) {
if (chunk != null && chunk.isNotEmpty) yield chunk;
}
}
@override
Future<String?> sendChat({required AIRequestModel request}) async {
final result = await executeGenAIRequest(request);