import 'package:dio/dio.dart';
import '../../domain/repositories/chat_repository.dart';
import '../datasources/chat_remote_datasource.dart';

class ChatRepositoryImpl implements ChatRepository {
  final ChatRemoteDatasource remote;

  ChatRepositoryImpl(this.remote);

  @override
  Future<ChatResponseModel> sendMessage({
    required String sessionId,
    required String message,
    String? knowledgeBaseId,
  }) async {
    try {
      return await remote.sendMessage(
        sessionId: sessionId,
        message: message,
        knowledgeBaseId: knowledgeBaseId,
      );
    } on DioException catch (e) {
      throw e.error ?? e;
    }
  }
}