Skip to content

Commit

Permalink
🐛 fix: support Gemini 2.0 HarmBlockThreshold (#5422)
Browse files Browse the repository at this point in the history
* Update index.ts

* Update index.ts
  • Loading branch information
sxjeru authored Jan 14, 2025
1 parent 3cffc7e commit 4d1a4cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/libs/agent-runtime/google/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum HarmCategory {

enum HarmBlockThreshold {
BLOCK_NONE = 'BLOCK_NONE',
OFF = 'OFF', // https://discuss.ai.google.dev/t/59352
}

export class LobeGoogleAI implements LobeRuntimeAI {
Expand Down Expand Up @@ -70,19 +71,19 @@ export class LobeGoogleAI implements LobeRuntimeAI {
safetySettings: [
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_NONE,
threshold: model.includes('2.0') ? (HarmBlockThreshold.OFF as any) : HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
threshold: HarmBlockThreshold.BLOCK_NONE,
threshold: model.includes('2.0') ? (HarmBlockThreshold.OFF as any) : HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
threshold: model.includes('2.0') ? (HarmBlockThreshold.OFF as any) : HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
threshold: model.includes('2.0') ? (HarmBlockThreshold.OFF as any) : HarmBlockThreshold.BLOCK_NONE,
},
],
},
Expand Down

0 comments on commit 4d1a4cd

Please sign in to comment.