Feat: change Gemini Safety Settings to OFF; upgrade @google/genai package (#5763)

* Feat: change Gemini Safety Settings to OFF; upgrade @google/genai package

* fix: remove model.id param in getSafetySettings in Gemini Provider
This commit is contained in:
ous50 | ousfifty | 欧式fifty 2025-05-08 18:21:39 +08:00 committed by GitHub
parent 9390b92ebb
commit 5f09cd2718
3 changed files with 18 additions and 14 deletions

View File

@ -118,7 +118,7 @@
"@emotion/is-prop-valid": "^1.3.1",
"@eslint-react/eslint-plugin": "^1.36.1",
"@eslint/js": "^9.22.0",
"@google/genai": "^0.10.0",
"@google/genai": "^0.13.0",
"@hello-pangea/dnd": "^16.6.0",
"@iconify-json/svg-spinners": "^1.2.2",
"@kangfenmao/keyv-storage": "^0.1.0",

View File

@ -178,13 +178,10 @@ export default class GeminiProvider extends BaseProvider {
/**
* Get the safety settings
* @param modelId - The model ID
* @returns The safety settings
*/
private getSafetySettings(modelId: string): SafetySetting[] {
const safetyThreshold = modelId.includes('gemini-2.0-flash-exp')
? ('OFF' as HarmBlockThreshold)
: HarmBlockThreshold.BLOCK_NONE
private getSafetySettings(): SafetySetting[] {
const safetyThreshold = 'OFF' as HarmBlockThreshold
return [
{
@ -204,8 +201,8 @@ export default class GeminiProvider extends BaseProvider {
threshold: safetyThreshold
},
{
category: 'HARM_CATEGORY_CIVIC_INTEGRITY' as HarmCategory,
threshold: safetyThreshold
category: HarmCategory.HARM_CATEGORY_CIVIC_INTEGRITY,
threshold: HarmBlockThreshold.BLOCK_NONE
}
]
}
@ -310,7 +307,7 @@ export default class GeminiProvider extends BaseProvider {
const generateContentConfig: GenerateContentConfig = {
responseModalities: canGenerateImage ? [Modality.TEXT, Modality.IMAGE] : undefined,
responseMimeType: canGenerateImage ? 'text/plain' : undefined,
safetySettings: this.getSafetySettings(model.id),
safetySettings: this.getSafetySettings(),
// generate image don't need system instruction
systemInstruction: isGemmaModel(model) || canGenerateImage ? undefined : systemInstruction,
temperature: assistant?.settings?.temperature,

View File

@ -1476,15 +1476,22 @@ __metadata:
languageName: node
linkType: hard
"@google/genai@npm:^0.10.0":
version: 0.10.0
resolution: "@google/genai@npm:0.10.0"
"@google/genai@npm:^0.13.0":
version: 0.13.0
resolution: "@google/genai@npm:0.13.0"
dependencies:
google-auth-library: "npm:^9.14.2"
ws: "npm:^8.18.0"
zod: "npm:^3.22.4"
zod-to-json-schema: "npm:^3.22.4"
checksum: 10c0/89a80eebdd053f2643fb977b939c3de1ece6889549f7d030b81a21dae0e0e0750233e453dafe665f8d337c642b4ba7a2f19b06bc270f3e2de8aeb803af1851d1
checksum: 10c0/b520e6154bd9cefa725f897ee521e97c59c287d23031a36c946385eef409e411d34dd8e43d5a7c618e3572ea5fd5bef86474585ba936d5b42f7655e03b83290b
languageName: node
linkType: hard
"@google/generative-ai@npm:^0.24.1":
version: 0.24.1
resolution: "@google/generative-ai@npm:0.24.1"
checksum: 10c0/8da77fc648b04fc2ecef53e75230e2ee67a8fd29a34b6b8874e77a7332b2a1e4b51d44dd9eb604fb063ed8ea46d293aac5b1e2a955ae2435e2582a265f2cb80d
languageName: node
linkType: hard
@ -4392,7 +4399,7 @@ __metadata:
"@emotion/is-prop-valid": "npm:^1.3.1"
"@eslint-react/eslint-plugin": "npm:^1.36.1"
"@eslint/js": "npm:^9.22.0"
"@google/genai": "npm:^0.10.0"
"@google/genai": "npm:^0.13.0"
"@hello-pangea/dnd": "npm:^16.6.0"
"@iconify-json/svg-spinners": "npm:^1.2.2"
"@kangfenmao/keyv-storage": "npm:^0.1.0"