diff --git a/SovereignAI-Starter/flutter_app/lib/core/network/api_repository.dart b/SovereignAI-Starter/flutter_app/lib/core/network/api_repository.dart index f27c1aa..6f4f454 100644 --- a/SovereignAI-Starter/flutter_app/lib/core/network/api_repository.dart +++ b/SovereignAI-Starter/flutter_app/lib/core/network/api_repository.dart @@ -22,6 +22,13 @@ class ApiRepository { void setBaseUrl(String value) => _baseUrl = value.replaceFirst(RegExp(r'/+$'), ''); + Future getModelName() async { + final response = await http.get(Uri.parse('$_baseUrl/health')); + _checkStatus(response); + final data = jsonDecode(response.body) as Map; + return data['model'] as String? ?? 'نموذج غير معروف'; + } + Future _userId() async { final cached = _cachedUserId; if (cached != null) return cached; diff --git a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_cubit.dart b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_cubit.dart index 0a0cbc1..06aa17d 100644 --- a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_cubit.dart +++ b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_cubit.dart @@ -6,10 +6,20 @@ import 'chat_state.dart'; class ChatCubit extends Cubit { ChatCubit(this._api) : super(ChatState(apiBaseUrl: _api.baseUrl)) { _loadHistory(); + _loadModelName(); } final ApiRepository _api; + Future _loadModelName() async { + try { + final modelName = await _api.getModelName(); + if (!isClosed) emit(state.copyWith(modelName: modelName)); + } catch (_) { + if (!isClosed) emit(state.copyWith(modelName: 'تعذر الاتصال بالخادم')); + } + } + Future _loadHistory() async { try { final conversations = await _api.listConversations(); @@ -172,5 +182,6 @@ class ChatCubit extends Cubit { if (url.isEmpty) return; _api.setBaseUrl(url); emit(state.copyWith(apiBaseUrl: _api.baseUrl, clearError: true)); + _loadModelName(); } } diff --git a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_state.dart b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_state.dart index 68fd012..0fc7347 100644 --- a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_state.dart +++ b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/cubit/chat_state.dart @@ -60,6 +60,7 @@ class ChatState { this.isLoadingHistory = true, this.isSending = false, this.error, + this.modelName = 'جارٍ اكتشاف النموذج…', required this.apiBaseUrl, }); @@ -69,6 +70,7 @@ class ChatState { final bool isLoadingHistory; final bool isSending; final String? error; + final String modelName; final String apiBaseUrl; ChatState copyWith({ @@ -80,6 +82,7 @@ class ChatState { bool? isSending, String? error, bool clearError = false, + String? modelName, String? apiBaseUrl, }) => ChatState( messages: messages ?? this.messages, @@ -91,6 +94,7 @@ class ChatState { isLoadingHistory: isLoadingHistory ?? this.isLoadingHistory, isSending: isSending ?? this.isSending, error: clearError ? null : (error ?? this.error), + modelName: modelName ?? this.modelName, apiBaseUrl: apiBaseUrl ?? this.apiBaseUrl, ); } diff --git a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/pages/chat_page.dart b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/pages/chat_page.dart index 207abbd..ce6ae20 100644 --- a/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/pages/chat_page.dart +++ b/SovereignAI-Starter/flutter_app/lib/features/chat/presentation/pages/chat_page.dart @@ -293,8 +293,8 @@ class _ChatPageState extends State { ], ), const SizedBox(height: 7), - const Text( - 'qwen2.5:1.5b-instruct-q4_K_M', + Text( + chat.modelName, textDirection: TextDirection.ltr, style: TextStyle(fontSize: 10, color: Color(0xFF718078)), ),