mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 10:17:47 +08:00
refactor: remove streaming functionality from ChatRemoteRepository and add tests
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user