Skip to content

Commit

Permalink
fix(chat-models): Throw exception if a system message passed to gemini (
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz authored and KennethKnudsen97 committed Apr 22, 2024
1 parent d5d4732 commit c59bc9d
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ extension ChatMessagesMapper on List<ChatMessage> {
List<Content> toContentList() {
return map(
(final message) => switch (message) {
// Gemini does not support system messages yet, so we include it as user message
final SystemChatMessage msg => Content(
role: _authorUser,
parts: [Part(text: msg.content)],
SystemChatMessage() => throw UnsupportedError(
'Google AI does not support system messages at the moment. '
'Attach your system message in the human message.',
),
final HumanChatMessage msg => Content(
role: _authorUser,
Expand Down

0 comments on commit c59bc9d

Please sign in to comment.