mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-03 19:42:57 +00:00
small fix, don't worry about it
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user