Gemini: AI_UnsupportedFunctionalityError: system messages are only supported at the beginning of the conversation
Description
I recently updated my packages and started receiving an error for the Gemini Flash 1.5 AI model. I understand that the system message should come first, but is this a requirement for Google Gemini? I checked the Gemini documentation but couldn't find any information on the order of the system message.
PS: Keeping the system message at last improves the response quality for some models.
Error: [AI_UnsupportedFunctionalityError: 'system messages are only supported at the beginning of the conversation' functionality not supported.] {
name: 'AI_UnsupportedFunctionalityError',
functionality: 'system messages are only supported at the beginning of the conversation'
}
error in streaming generateResponse API [AI_UnsupportedFunctionalityError: 'system messages are only supported at the beginning of the conversation' functionality not supported.] {
name: 'AI_UnsupportedFunctionalityError',
functionality: 'system messages are only supported at the beginning of the conversation'
}
stack trace: AI_UnsupportedFunctionalityError: 'system messages are only supported at the beginning of the conversation' functionality not supported.
at convertToGoogleGenerativeAIMessages (webpack-internal:///(middleware)/./node_modules/.pnpm/@[email protected][email protected]/node_modules/@ai-sdk/google/dist/index.mjs:32:17)
at GoogleGenerativeAILanguageModel.getArgs (webpack-internal:///(middleware)/./node_modules/.pnpm/@[email protected][email protected]/node_modules/@ai-sdk/google/dist/index.mjs:209:51)
at GoogleGenerativeAILanguageModel.doStream (webpack-internal:///(middleware)/./node_modules/.pnpm/@[email protected][email protected]/node_modules/@ai-sdk/google/dist/index.mjs:307:43)
at fn (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:1974:35)
at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:1363:28)
at Object.startActiveSpan (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:1292:14)
at recordSpan (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:1361:17)
at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:1963:15)
at _retryWithExponentialBackoff (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:122:18)
at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_b6x64b64e4vtih556h5y2ochom/node_modules/ai/dist/index.mjs:111:25)
Code example
No response
Additional context
"@ai-sdk/google": "^0.0.27",
"ai": "^3.2.33"
I think since the Gemini API returned this error, it means that's how it is
But if I revert ai-sdk/google to the previous version (0.0.26), the error doesn't appear.
i am facing the same error , and same If i revert ai-sdk/google to the previous version (0.0.26), the error doesn't appear.
I think you can use another provider model then system message will supports.