Skip to content

Commit ac04a1c

Browse files
committed
resolve conflicts
2 parents 87a286e + 622d8a4 commit ac04a1c

7 files changed

Lines changed: 50 additions & 6 deletions

File tree

app/client/platforms/google.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export class GeminiProApi implements LLMApi {
106106
// if (visionModel && messages.length > 1) {
107107
// options.onError?.(new Error("Multiturn chat is not enabled for models/gemini-pro-vision"));
108108
// }
109+
110+
const accessStore = useAccessStore.getState();
111+
109112
const modelConfig = {
110113
...useAppConfig.getState().modelConfig,
111114
...useChatStore.getState().currentSession().mask.modelConfig,
@@ -127,19 +130,19 @@ export class GeminiProApi implements LLMApi {
127130
safetySettings: [
128131
{
129132
category: "HARM_CATEGORY_HARASSMENT",
130-
threshold: "BLOCK_ONLY_HIGH",
133+
threshold: accessStore.googleSafetySettings,
131134
},
132135
{
133136
category: "HARM_CATEGORY_HATE_SPEECH",
134-
threshold: "BLOCK_ONLY_HIGH",
137+
threshold: accessStore.googleSafetySettings,
135138
},
136139
{
137140
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
138-
threshold: "BLOCK_ONLY_HIGH",
141+
threshold: accessStore.googleSafetySettings,
139142
},
140143
{
141144
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
142-
threshold: "BLOCK_ONLY_HIGH",
145+
threshold: accessStore.googleSafetySettings,
143146
},
144147
],
145148
};

app/components/settings.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
ByteDance,
5858
Alibaba,
5959
Google,
60+
GoogleSafetySettingsThreshold,
6061
OPENAI_BASE_URL,
6162
Path,
6263
RELEASE_URL,
@@ -833,6 +834,27 @@ export function Settings() {
833834
}
834835
></input>
835836
</ListItem>
837+
<ListItem
838+
title={Locale.Settings.Access.Google.GoogleSafetySettings.Title}
839+
subTitle={Locale.Settings.Access.Google.GoogleSafetySettings.SubTitle}
840+
>
841+
<Select
842+
value={accessStore.googleSafetySettings}
843+
onChange={(e) => {
844+
accessStore.update(
845+
(access) =>
846+
(access.googleSafetySettings = e.target
847+
.value as GoogleSafetySettingsThreshold),
848+
);
849+
}}
850+
>
851+
{Object.entries(GoogleSafetySettingsThreshold).map(([k, v]) => (
852+
<option value={v} key={k}>
853+
{k}
854+
</option>
855+
))}
856+
</Select>
857+
</ListItem>
836858
</>
837859
);
838860

app/constant.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ export enum ServiceProvider {
9090
Alibaba = "Alibaba",
9191
}
9292

93+
// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
94+
// BLOCK_NONE will not block any content, and BLOCK_ONLY_HIGH will block only high-risk content.
95+
export enum GoogleSafetySettingsThreshold {
96+
BLOCK_NONE = "BLOCK_NONE",
97+
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
98+
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
99+
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
100+
}
101+
93102
export enum ModelProvider {
94103
GPT = "GPT",
95104
GeminiPro = "GeminiPro",
@@ -176,7 +185,7 @@ Latex inline: \\(x^2\\)
176185
Latex block: $$e=mc^2$$
177186
`;
178187

179-
export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
188+
export const SUMMARIZE_MODEL = "gpt-4o-mini";
180189
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
181190

182191
export const KnowledgeCutOffDate: Record<string, string> = {

app/locales/cn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ const cn = {
346346
Title: "API 版本(仅适用于 gemini-pro)",
347347
SubTitle: "选择一个特定的 API 版本",
348348
},
349+
GoogleSafetySettings: {
350+
Title: "Google 安全过滤级别",
351+
SubTitle: "设置内容过滤级别",
352+
},
349353
},
350354
Baidu: {
351355
ApiKey: {

app/locales/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ const en: LocaleType = {
392392
Title: "API Version (specific to gemini-pro)",
393393
SubTitle: "Select a specific API version",
394394
},
395+
GoogleSafetySettings: {
396+
Title: "Google Safety Settings",
397+
SubTitle: "Select a safety filtering level",
398+
},
395399
},
396400
},
397401

app/store/access.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ApiPath,
33
DEFAULT_API_HOST,
4+
GoogleSafetySettingsThreshold,
45
ServiceProvider,
56
StoreKey,
67
} from "../constant";
@@ -59,6 +60,7 @@ const DEFAULT_ACCESS_STATE = {
5960
googleUrl: DEFAULT_GOOGLE_URL,
6061
googleApiKey: "",
6162
googleApiVersion: "v1",
63+
googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH,
6264

6365
// anthropic
6466
anthropicUrl: DEFAULT_ANTHROPIC_URL,

app/store/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function createEmptySession(): ChatSession {
9090
}
9191

9292
function getSummarizeModel(currentModel: string) {
93-
// if it is using gpt-* models, force to use 3.5 to summarize
93+
// if it is using gpt-* models, force to use 4o-mini to summarize
9494
if (currentModel.startsWith("gpt")) {
9595
const configStore = useAppConfig.getState();
9696
const accessStore = useAccessStore.getState();

0 commit comments

Comments
 (0)