small fix, don't worry about it

This commit is contained in:
Tomas Dvorak
2026-04-10 12:05:40 +02:00
parent 7b7ed0083f
commit 5ab2773f98
55 changed files with 3240 additions and 483 deletions
@@ -117,10 +117,23 @@ If user context is provided, use it to personalise your responses while respecti
if (response.statusCode == 200) {
final data = jsonDecode(response.body) as Map<String, dynamic>;
final choices = data['choices'] as List;
final firstChoice = choices.first as Map<String, dynamic>;
final message = firstChoice['message'] as Map<String, dynamic>;
return message['content'] as String;
final choices = data['choices'] as List?;
if (choices == null || choices.isEmpty) {
throw MistralAIException('No choices returned in response');
}
final firstChoice = choices.first as Map<String, dynamic>?;
if (firstChoice == null) {
throw MistralAIException('Invalid choice format in response');
}
final message = firstChoice['message'] as Map<String, dynamic>?;
if (message == null) {
throw MistralAIException('No message in choice');
}
final content = message['content'] as String?;
if (content == null) {
throw MistralAIException('No content in message');
}
return content;
} else {
throw MistralAIException(
'Failed to get chat response',