mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
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:
parent
191aafe1fc
commit
cdbba49dd5
@ -118,7 +118,7 @@
|
|||||||
"@emotion/is-prop-valid": "^1.3.1",
|
"@emotion/is-prop-valid": "^1.3.1",
|
||||||
"@eslint-react/eslint-plugin": "^1.36.1",
|
"@eslint-react/eslint-plugin": "^1.36.1",
|
||||||
"@eslint/js": "^9.22.0",
|
"@eslint/js": "^9.22.0",
|
||||||
"@google/genai": "^0.10.0",
|
"@google/genai": "^0.13.0",
|
||||||
"@hello-pangea/dnd": "^16.6.0",
|
"@hello-pangea/dnd": "^16.6.0",
|
||||||
"@iconify-json/svg-spinners": "^1.2.2",
|
"@iconify-json/svg-spinners": "^1.2.2",
|
||||||
"@kangfenmao/keyv-storage": "^0.1.0",
|
"@kangfenmao/keyv-storage": "^0.1.0",
|
||||||
|
|||||||
@ -178,13 +178,10 @@ export default class GeminiProvider extends BaseProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the safety settings
|
* Get the safety settings
|
||||||
* @param modelId - The model ID
|
|
||||||
* @returns The safety settings
|
* @returns The safety settings
|
||||||
*/
|
*/
|
||||||
private getSafetySettings(modelId: string): SafetySetting[] {
|
private getSafetySettings(): SafetySetting[] {
|
||||||
const safetyThreshold = modelId.includes('gemini-2.0-flash-exp')
|
const safetyThreshold = 'OFF' as HarmBlockThreshold
|
||||||
? ('OFF' as HarmBlockThreshold)
|
|
||||||
: HarmBlockThreshold.BLOCK_NONE
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -204,8 +201,8 @@ export default class GeminiProvider extends BaseProvider {
|
|||||||
threshold: safetyThreshold
|
threshold: safetyThreshold
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
category: 'HARM_CATEGORY_CIVIC_INTEGRITY' as HarmCategory,
|
category: HarmCategory.HARM_CATEGORY_CIVIC_INTEGRITY,
|
||||||
threshold: safetyThreshold
|
threshold: HarmBlockThreshold.BLOCK_NONE
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -310,7 +307,7 @@ export default class GeminiProvider extends BaseProvider {
|
|||||||
const generateContentConfig: GenerateContentConfig = {
|
const generateContentConfig: GenerateContentConfig = {
|
||||||
responseModalities: canGenerateImage ? [Modality.TEXT, Modality.IMAGE] : undefined,
|
responseModalities: canGenerateImage ? [Modality.TEXT, Modality.IMAGE] : undefined,
|
||||||
responseMimeType: canGenerateImage ? 'text/plain' : undefined,
|
responseMimeType: canGenerateImage ? 'text/plain' : undefined,
|
||||||
safetySettings: this.getSafetySettings(model.id),
|
safetySettings: this.getSafetySettings(),
|
||||||
// generate image don't need system instruction
|
// generate image don't need system instruction
|
||||||
systemInstruction: isGemmaModel(model) || canGenerateImage ? undefined : systemInstruction,
|
systemInstruction: isGemmaModel(model) || canGenerateImage ? undefined : systemInstruction,
|
||||||
temperature: assistant?.settings?.temperature,
|
temperature: assistant?.settings?.temperature,
|
||||||
|
|||||||
17
yarn.lock
17
yarn.lock
@ -1476,15 +1476,22 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@google/genai@npm:^0.10.0":
|
"@google/genai@npm:^0.13.0":
|
||||||
version: 0.10.0
|
version: 0.13.0
|
||||||
resolution: "@google/genai@npm:0.10.0"
|
resolution: "@google/genai@npm:0.13.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
google-auth-library: "npm:^9.14.2"
|
google-auth-library: "npm:^9.14.2"
|
||||||
ws: "npm:^8.18.0"
|
ws: "npm:^8.18.0"
|
||||||
zod: "npm:^3.22.4"
|
zod: "npm:^3.22.4"
|
||||||
zod-to-json-schema: "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
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -4392,7 +4399,7 @@ __metadata:
|
|||||||
"@emotion/is-prop-valid": "npm:^1.3.1"
|
"@emotion/is-prop-valid": "npm:^1.3.1"
|
||||||
"@eslint-react/eslint-plugin": "npm:^1.36.1"
|
"@eslint-react/eslint-plugin": "npm:^1.36.1"
|
||||||
"@eslint/js": "npm:^9.22.0"
|
"@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"
|
"@hello-pangea/dnd": "npm:^16.6.0"
|
||||||
"@iconify-json/svg-spinners": "npm:^1.2.2"
|
"@iconify-json/svg-spinners": "npm:^1.2.2"
|
||||||
"@kangfenmao/keyv-storage": "npm:^0.1.0"
|
"@kangfenmao/keyv-storage": "npm:^0.1.0"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user