From bda4d8af59082d2851c02987d899b172cee7afec Mon Sep 17 00:00:00 2001 From: Pylogmon Date: Wed, 20 Dec 2023 22:22:07 +0800 Subject: [PATCH] fix: Remove Safety Block --- src/services/translate/geminipro/index.jsx | 18 ++++++++++++++++++ .../translate/geminipro_custom/index.jsx | 18 ++++++++++++++++++ .../translate/geminipro_polish/index.jsx | 18 ++++++++++++++++++ .../translate/geminipro_summary/index.jsx | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/src/services/translate/geminipro/index.jsx b/src/services/translate/geminipro/index.jsx index 43a4704a68..8c2bc96c6f 100644 --- a/src/services/translate/geminipro/index.jsx +++ b/src/services/translate/geminipro/index.jsx @@ -35,6 +35,24 @@ export async function translate(text, from, to, options = {}) { }; let body = { contents: promptList, + safetySettings: [ + { + category: 'HARM_CATEGORY_HARASSMENT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_HATE_SPEECH', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_DANGEROUS_CONTENT', + threshold: 'BLOCK_NONE', + }, + ], }; if (stream) { diff --git a/src/services/translate/geminipro_custom/index.jsx b/src/services/translate/geminipro_custom/index.jsx index 1506948e45..e560504d95 100644 --- a/src/services/translate/geminipro_custom/index.jsx +++ b/src/services/translate/geminipro_custom/index.jsx @@ -35,6 +35,24 @@ export async function translate(text, from, to, options = {}) { }; let body = { contents: promptList, + safetySettings: [ + { + category: 'HARM_CATEGORY_HARASSMENT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_HATE_SPEECH', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_DANGEROUS_CONTENT', + threshold: 'BLOCK_NONE', + }, + ], }; if (stream) { diff --git a/src/services/translate/geminipro_polish/index.jsx b/src/services/translate/geminipro_polish/index.jsx index 10cdcc62ba..f8f69e4ae9 100644 --- a/src/services/translate/geminipro_polish/index.jsx +++ b/src/services/translate/geminipro_polish/index.jsx @@ -35,6 +35,24 @@ export async function translate(text, from, to, options = {}) { }; let body = { contents: promptList, + safetySettings: [ + { + category: 'HARM_CATEGORY_HARASSMENT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_HATE_SPEECH', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_DANGEROUS_CONTENT', + threshold: 'BLOCK_NONE', + }, + ], }; if (stream) { diff --git a/src/services/translate/geminipro_summary/index.jsx b/src/services/translate/geminipro_summary/index.jsx index b23c430be0..ebc4058756 100644 --- a/src/services/translate/geminipro_summary/index.jsx +++ b/src/services/translate/geminipro_summary/index.jsx @@ -35,6 +35,24 @@ export async function translate(text, from, to, options = {}) { }; let body = { contents: promptList, + safetySettings: [ + { + category: 'HARM_CATEGORY_HARASSMENT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_HATE_SPEECH', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + threshold: 'BLOCK_NONE', + }, + { + category: 'HARM_CATEGORY_DANGEROUS_CONTENT', + threshold: 'BLOCK_NONE', + }, + ], }; if (stream) {