diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts
index 753a768c6..1f55beebc 100644
--- a/app/client/platforms/google.ts
+++ b/app/client/platforms/google.ts
@@ -106,6 +106,9 @@ export class GeminiProApi implements LLMApi {
// if (visionModel && messages.length > 1) {
// options.onError?.(new Error("Multiturn chat is not enabled for models/gemini-pro-vision"));
// }
+
+ const accessStore = useAccessStore.getState();
+
const modelConfig = {
...useAppConfig.getState().modelConfig,
...useChatStore.getState().currentSession().mask.modelConfig,
@@ -127,19 +130,19 @@ export class GeminiProApi implements LLMApi {
safetySettings: [
{
category: "HARM_CATEGORY_HARASSMENT",
- threshold: "BLOCK_ONLY_HIGH",
+ threshold: accessStore.googleSafetySettings,
},
{
category: "HARM_CATEGORY_HATE_SPEECH",
- threshold: "BLOCK_ONLY_HIGH",
+ threshold: accessStore.googleSafetySettings,
},
{
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
- threshold: "BLOCK_ONLY_HIGH",
+ threshold: accessStore.googleSafetySettings,
},
{
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
- threshold: "BLOCK_ONLY_HIGH",
+ threshold: accessStore.googleSafetySettings,
},
],
};
diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index ad63b2b90..e95722f1d 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -57,6 +57,7 @@ import {
ByteDance,
Alibaba,
Google,
+ GoogleSafetySettingsThreshold,
OPENAI_BASE_URL,
Path,
RELEASE_URL,
@@ -833,6 +834,27 @@ export function Settings() {
}
>
+
+
+
>
);
diff --git a/app/constant.ts b/app/constant.ts
index f5d3c77f4..0e3d76fac 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -90,6 +90,15 @@ export enum ServiceProvider {
Alibaba = "Alibaba",
}
+// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
+// BLOCK_NONE will not block any content, and BLOCK_ONLY_HIGH will block only high-risk content.
+export enum GoogleSafetySettingsThreshold {
+ BLOCK_NONE = "BLOCK_NONE",
+ BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
+ BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
+ BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
+}
+
export enum ModelProvider {
GPT = "GPT",
GeminiPro = "GeminiPro",
@@ -176,7 +185,7 @@ Latex inline: \\(x^2\\)
Latex block: $$e=mc^2$$
`;
-export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
+export const SUMMARIZE_MODEL = "gpt-4o-mini";
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
export const KnowledgeCutOffDate: Record = {
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index 4b93677d4..43ea67633 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -346,6 +346,10 @@ const cn = {
Title: "API 版本(仅适用于 gemini-pro)",
SubTitle: "选择一个特定的 API 版本",
},
+ GoogleSafetySettings: {
+ Title: "Google 安全过滤级别",
+ SubTitle: "设置内容过滤级别",
+ },
},
Baidu: {
ApiKey: {
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 1e4890107..94c737550 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -392,6 +392,10 @@ const en: LocaleType = {
Title: "API Version (specific to gemini-pro)",
SubTitle: "Select a specific API version",
},
+ GoogleSafetySettings: {
+ Title: "Google Safety Settings",
+ SubTitle: "Select a safety filtering level",
+ },
},
},
diff --git a/app/store/access.ts b/app/store/access.ts
index 26359e55c..24d7e175a 100644
--- a/app/store/access.ts
+++ b/app/store/access.ts
@@ -1,6 +1,7 @@
import {
ApiPath,
DEFAULT_API_HOST,
+ GoogleSafetySettingsThreshold,
ServiceProvider,
StoreKey,
} from "../constant";
@@ -59,6 +60,7 @@ const DEFAULT_ACCESS_STATE = {
googleUrl: DEFAULT_GOOGLE_URL,
googleApiKey: "",
googleApiVersion: "v1",
+ googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH,
// anthropic
anthropicUrl: DEFAULT_ANTHROPIC_URL,
diff --git a/app/store/chat.ts b/app/store/chat.ts
index 9372b8b2e..5892ef0c8 100644
--- a/app/store/chat.ts
+++ b/app/store/chat.ts
@@ -90,7 +90,7 @@ function createEmptySession(): ChatSession {
}
function getSummarizeModel(currentModel: string) {
- // if it is using gpt-* models, force to use 3.5 to summarize
+ // if it is using gpt-* models, force to use 4o-mini to summarize
if (currentModel.startsWith("gpt")) {
const configStore = useAppConfig.getState();
const accessStore = useAccessStore.getState();