Files
apidash/packages/genai/lib/models/ai_request_model.dart
Ankit Mahato 72fea1ba65 Refactor genai package to new modular interface
Reorganized the genai package by removing legacy LLM-related files and introducing a new modular interface under the 'interface' directory. Added provider-specific model classes, centralized constants, and updated the example to use the new API and data structures. Updated exports in genai.dart and improved dependency management.
2025-08-27 02:08:36 +05:30

30 lines
974 B
Dart

import 'package:better_networking/better_networking.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../interface/interface.dart';
import 'model_request_data.dart';
part 'ai_request_model.freezed.dart';
part 'ai_request_model.g.dart';
@freezed
class AIRequestModel with _$AIRequestModel {
const AIRequestModel._();
@JsonSerializable(explicitToJson: true, anyMap: true)
const factory AIRequestModel({
ModelAPIProvider? modelProvider,
ModelRequestData? modelRequestData,
}) = _AIRequestModel;
factory AIRequestModel.fromJson(Map<String, Object?> json) =>
_$AIRequestModelFromJson(json);
HttpRequestModel? get httpRequestModel =>
kModelProvidersMap[modelProvider]?.createRequest(modelRequestData);
String? getFormattedOutput(Map x) =>
kModelProvidersMap[modelProvider]?.outputFormatter(x);
String? getFormattedStreamOutput(Map x) =>
kModelProvidersMap[modelProvider]?.streamOutputFormatter(x);
}