Merge remote-tracking branch 'upstream/main' into dev

# Conflicts:
#	app/components/settings.tsx
#	app/constant.ts
#	app/store/chat.ts
This commit is contained in:
sijinhui 2024-07-21 07:25:36 +08:00
commit c8f2d8029b
8 changed files with 497 additions and 485 deletions

View File

@ -106,6 +106,9 @@ export class GeminiProApi implements LLMApi {
// if (visionModel && messages.length > 1) { // if (visionModel && messages.length > 1) {
// options.onError?.(new Error("Multiturn chat is not enabled for models/gemini-pro-vision")); // options.onError?.(new Error("Multiturn chat is not enabled for models/gemini-pro-vision"));
// } // }
const accessStore = useAccessStore.getState();
const modelConfig = { const modelConfig = {
...useAppConfig.getState().modelConfig, ...useAppConfig.getState().modelConfig,
...useChatStore.getState().currentSession().mask.modelConfig, ...useChatStore.getState().currentSession().mask.modelConfig,
@ -127,19 +130,19 @@ export class GeminiProApi implements LLMApi {
safetySettings: [ safetySettings: [
{ {
category: "HARM_CATEGORY_HARASSMENT", category: "HARM_CATEGORY_HARASSMENT",
threshold: "BLOCK_ONLY_HIGH", threshold: accessStore.googleSafetySettings,
}, },
{ {
category: "HARM_CATEGORY_HATE_SPEECH", category: "HARM_CATEGORY_HATE_SPEECH",
threshold: "BLOCK_ONLY_HIGH", threshold: accessStore.googleSafetySettings,
}, },
{ {
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT", category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
threshold: "BLOCK_ONLY_HIGH", threshold: accessStore.googleSafetySettings,
}, },
{ {
category: "HARM_CATEGORY_DANGEROUS_CONTENT", category: "HARM_CATEGORY_DANGEROUS_CONTENT",
threshold: "BLOCK_ONLY_HIGH", threshold: accessStore.googleSafetySettings,
}, },
], ],
}; };

View File

@ -57,6 +57,7 @@ import {
ByteDance, ByteDance,
Alibaba, Alibaba,
Google, Google,
GoogleSafetySettingsThreshold,
OPENAI_BASE_URL, OPENAI_BASE_URL,
Path, Path,
RELEASE_URL, RELEASE_URL,
@ -657,6 +658,389 @@ export function Settings() {
const clientConfig = useMemo(() => getClientConfig(), []); const clientConfig = useMemo(() => getClientConfig(), []);
const showAccessCode = enabledAccessControl && !clientConfig?.isApp; const showAccessCode = enabledAccessControl && !clientConfig?.isApp;
const accessCodeComponent = showAccessCode && (
<ListItem
title={Locale.Settings.Access.AccessCode.Title}
subTitle={Locale.Settings.Access.AccessCode.SubTitle}
>
<PasswordInput
value={accessStore.accessCode}
type="text"
placeholder={Locale.Settings.Access.AccessCode.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.accessCode = e.currentTarget.value),
);
}}
/>
</ListItem>
);
const useCustomConfigComponent = // Conditionally render the following ListItem based on clientConfig.isApp
!clientConfig?.isApp && ( // only show if isApp is false
<ListItem
title={Locale.Settings.Access.CustomEndpoint.Title}
subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}
>
<input
type="checkbox"
checked={accessStore.useCustomConfig}
onChange={(e) =>
accessStore.update(
(access) => (access.useCustomConfig = e.currentTarget.checked),
)
}
></input>
</ListItem>
);
const openAIConfigComponent = accessStore.provider ===
ServiceProvider.OpenAI && (
<>
<ListItem
title={Locale.Settings.Access.OpenAI.Endpoint.Title}
subTitle={Locale.Settings.Access.OpenAI.Endpoint.SubTitle}
>
<input
type="text"
value={accessStore.openaiUrl}
placeholder={OPENAI_BASE_URL}
onChange={(e) =>
accessStore.update(
(access) => (access.openaiUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.OpenAI.ApiKey.Title}
subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.openaiApiKey}
type="text"
placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.openaiApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
const azureConfigComponent = accessStore.provider ===
ServiceProvider.Azure && (
<>
<ListItem
title={Locale.Settings.Access.Azure.Endpoint.Title}
subTitle={
Locale.Settings.Access.Azure.Endpoint.SubTitle + Azure.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.azureUrl}
placeholder={Azure.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.azureUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Azure.ApiKey.Title}
subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.azureApiKey}
type="text"
placeholder={Locale.Settings.Access.Azure.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.azureApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Azure.ApiVerion.Title}
subTitle={Locale.Settings.Access.Azure.ApiVerion.SubTitle}
>
<input
type="text"
value={accessStore.azureApiVersion}
placeholder="2023-08-01-preview"
onChange={(e) =>
accessStore.update(
(access) => (access.azureApiVersion = e.currentTarget.value),
)
}
></input>
</ListItem>
</>
);
const googleConfigComponent = accessStore.provider ===
ServiceProvider.Google && (
<>
<ListItem
title={Locale.Settings.Access.Google.Endpoint.Title}
subTitle={
Locale.Settings.Access.Google.Endpoint.SubTitle +
Google.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.googleUrl}
placeholder={Google.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.googleUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Google.ApiKey.Title}
subTitle={Locale.Settings.Access.Google.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.googleApiKey}
type="text"
placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.googleApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Google.ApiVersion.Title}
subTitle={Locale.Settings.Access.Google.ApiVersion.SubTitle}
>
<input
type="text"
value={accessStore.googleApiVersion}
placeholder="2023-08-01-preview"
onChange={(e) =>
accessStore.update(
(access) => (access.googleApiVersion = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Google.GoogleSafetySettings.Title}
subTitle={Locale.Settings.Access.Google.GoogleSafetySettings.SubTitle}
>
<Select
value={accessStore.googleSafetySettings}
onChange={(e) => {
accessStore.update(
(access) =>
(access.googleSafetySettings = e.target
.value as GoogleSafetySettingsThreshold),
);
}}
>
{Object.entries(GoogleSafetySettingsThreshold).map(([k, v]) => (
<option value={v} key={k}>
{k}
</option>
))}
</Select>
</ListItem>
</>
);
const anthropicConfigComponent = accessStore.provider ===
ServiceProvider.Anthropic && (
<>
<ListItem
title={Locale.Settings.Access.Anthropic.Endpoint.Title}
subTitle={
Locale.Settings.Access.Anthropic.Endpoint.SubTitle +
Anthropic.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.anthropicUrl}
placeholder={Anthropic.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.anthropicUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Anthropic.ApiKey.Title}
subTitle={Locale.Settings.Access.Anthropic.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.anthropicApiKey}
type="text"
placeholder={Locale.Settings.Access.Anthropic.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.anthropicApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Anthropic.ApiVerion.Title}
subTitle={Locale.Settings.Access.Anthropic.ApiVerion.SubTitle}
>
<input
type="text"
value={accessStore.anthropicApiVersion}
placeholder={Anthropic.Vision}
onChange={(e) =>
accessStore.update(
(access) => (access.anthropicApiVersion = e.currentTarget.value),
)
}
></input>
</ListItem>
</>
);
const baiduConfigComponent = accessStore.provider ===
ServiceProvider.Baidu && (
<>
<ListItem
title={Locale.Settings.Access.Baidu.Endpoint.Title}
subTitle={Locale.Settings.Access.Baidu.Endpoint.SubTitle}
>
<input
type="text"
value={accessStore.baiduUrl}
placeholder={Baidu.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.baiduUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Baidu.ApiKey.Title}
subTitle={Locale.Settings.Access.Baidu.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.baiduApiKey}
type="text"
placeholder={Locale.Settings.Access.Baidu.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.baiduApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Baidu.SecretKey.Title}
subTitle={Locale.Settings.Access.Baidu.SecretKey.SubTitle}
>
<PasswordInput
value={accessStore.baiduSecretKey}
type="text"
placeholder={Locale.Settings.Access.Baidu.SecretKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.baiduSecretKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
const byteDanceConfigComponent = accessStore.provider ===
ServiceProvider.ByteDance && (
<>
<ListItem
title={Locale.Settings.Access.ByteDance.Endpoint.Title}
subTitle={
Locale.Settings.Access.ByteDance.Endpoint.SubTitle +
ByteDance.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.bytedanceUrl}
placeholder={ByteDance.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.bytedanceUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.ByteDance.ApiKey.Title}
subTitle={Locale.Settings.Access.ByteDance.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.bytedanceApiKey}
type="text"
placeholder={Locale.Settings.Access.ByteDance.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.bytedanceApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
const alibabaConfigComponent = accessStore.provider ===
ServiceProvider.Alibaba && (
<>
<ListItem
title={Locale.Settings.Access.Alibaba.Endpoint.Title}
subTitle={
Locale.Settings.Access.Alibaba.Endpoint.SubTitle +
Alibaba.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.alibabaUrl}
placeholder={Alibaba.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.alibabaUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Alibaba.ApiKey.Title}
subTitle={Locale.Settings.Access.Alibaba.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.alibabaApiKey}
type="text"
placeholder={Locale.Settings.Access.Alibaba.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.alibabaApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
return ( return (
<ErrorBoundary> <ErrorBoundary>
<div className="window-header" data-tauri-drag-region> <div className="window-header" data-tauri-drag-region>
@ -902,491 +1286,95 @@ export function Settings() {
</ListItem> </ListItem>
</List> </List>
{/*<List id={SlotID.CustomModel}>*/} <!--
{/* {showAccessCode && (*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.AccessCode.Title}*/}
{/* subTitle={Locale.Settings.Access.AccessCode.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.accessCode}*/}
{/* type="text"*/}
{/* placeholder={Locale.Settings.Access.AccessCode.Placeholder}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) => (access.accessCode = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* )}*/}
{/*{!accessStore.hideUserApiKey && (*/} <List id={SlotID.CustomModel}>
{/* <>*/} {accessCodeComponent}
{/* {*/}
{/* // Conditionally render the following ListItem based on clientConfig.isApp*/}
{/* !clientConfig?.isApp && ( // only show if isApp is false*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.CustomEndpoint.Title}*/}
{/* subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}*/}
{/* >*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={accessStore.useCustomConfig}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.useCustomConfig = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* )*/}
{/* }*/}
{/* {accessStore.useCustomConfig && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Provider.Title}*/}
{/* subTitle={Locale.Settings.Access.Provider.SubTitle}*/}
{/* >*/}
{/* <Select*/}
{/* value={accessStore.provider}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.provider = e.target*/}
{/* .value as ServiceProvider),*/}
{/* );*/}
{/* }}*/}
{/* >*/}
{/* {Object.entries(ServiceProvider).map(([k, v]) => (*/}
{/* <option value={v} key={k}>*/}
{/* {k}*/}
{/* </option>*/}
{/* ))}*/}
{/* </Select>*/}
{/* </ListItem>*/}
{/*{accessStore.provider === ServiceProvider.OpenAI && (*/} {!accessStore.hideUserApiKey && (
{/* <>*/} <>
{/* <ListItem*/} {useCustomConfigComponent}
{/* title={Locale.Settings.Access.OpenAI.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.OpenAI.Endpoint.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.openaiUrl}*/}
{/* placeholder={OPENAI_BASE_URL}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.openaiUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.OpenAI.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.openaiApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.OpenAI.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.openaiApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* </>*/}
{/*)}*/}
{/*{accessStore.provider === ServiceProvider.Azure && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Azure.Endpoint.SubTitle +*/}
{/* Azure.ExampleEndpoint*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.azureUrl}*/}
{/* placeholder={Azure.ExampleEndpoint}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.azureApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Azure.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.ApiVerion.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Azure.ApiVerion.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.azureApiVersion}*/}
{/* placeholder="2023-08-01-preview"*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureApiVersion =*/}
{/* e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* </>*/}
{/*)}*/}
{/*{accessStore.provider === ServiceProvider.Google && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Google.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Google.Endpoint.SubTitle +*/}
{/* Google.ExampleEndpoint*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.googleUrl}*/}
{/* placeholder={Google.ExampleEndpoint}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.googleUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Google.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.Google.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.googleApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Google.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.googleApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Google.ApiVersion.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Google.ApiVersion.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.googleApiVersion}*/}
{/* placeholder="2023-08-01-preview"*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.googleApiVersion =*/}
{/* e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* </>*/}
{/*)}*/}
{/*{accessStore.provider === ServiceProvider.Anthropic && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Anthropic.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Anthropic.Endpoint.SubTitle +*/}
{/* Anthropic.ExampleEndpoint*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.anthropicUrl}*/}
{/* placeholder={Anthropic.ExampleEndpoint}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.anthropicUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Anthropic.ApiKey.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Anthropic.ApiKey.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.anthropicApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Anthropic.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.anthropicApiKey =*/}
{/* e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Anthropic.ApiVerion.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Anthropic.ApiVerion.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.anthropicApiVersion}*/}
{/* placeholder={Anthropic.Vision}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.anthropicApiVersion =*/}
{/* e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* </>*/}
{/*)}*/}
{/*{accessStore.provider === ServiceProvider.Baidu && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Baidu.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Baidu.Endpoint.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.baiduUrl}*/}
{/* placeholder={Baidu.ExampleEndpoint}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.baiduUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Baidu.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.Baidu.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.baiduApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Baidu.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.baiduApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Baidu.SecretKey.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Baidu.SecretKey.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.baiduSecretKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Baidu.SecretKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.baiduSecretKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* </>*/}
{/*)}*/}
{/* {accessStore.provider === ServiceProvider.ByteDance && (*/} {accessStore.useCustomConfig && (
{/* <>*/} <>
{/* <ListItem*/} <ListItem
{/* title={Locale.Settings.Access.ByteDance.Endpoint.Title}*/} title={Locale.Settings.Access.Provider.Title}
{/* subTitle={*/} subTitle={Locale.Settings.Access.Provider.SubTitle}
{/* Locale.Settings.Access.ByteDance.Endpoint.SubTitle +*/} >
{/* ByteDance.ExampleEndpoint*/} <Select
{/* }*/} value={accessStore.provider}
{/* >*/} onChange={(e) => {
{/* <input*/} accessStore.update(
{/* type="text"*/} (access) =>
{/* value={accessStore.bytedanceUrl}*/} (access.provider = e.target
{/* placeholder={ByteDance.ExampleEndpoint}*/} .value as ServiceProvider),
{/* onChange={(e) =>*/} );
{/* accessStore.update(*/} }}
{/* (access) =>*/} >
{/* (access.bytedanceUrl = e.currentTarget.value),*/} {Object.entries(ServiceProvider).map(([k, v]) => (
{/* )*/} <option value={v} key={k}>
{/* }*/} {k}
{/* ></input>*/} </option>
{/* </ListItem>*/} ))}
{/* <ListItem*/} </Select>
{/* title={Locale.Settings.Access.ByteDance.ApiKey.Title}*/} </ListItem>
{/* subTitle={*/}
{/* Locale.Settings.Access.ByteDance.ApiKey.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.bytedanceApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.ByteDance.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.bytedanceApiKey =*/}
{/* e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* </>*/}
{/* )}*/}
{/* {accessStore.provider === ServiceProvider.Alibaba && (*/} {openAIConfigComponent}
{/* <>*/} {azureConfigComponent}
{/* <ListItem*/} {googleConfigComponent}
{/* title={Locale.Settings.Access.Alibaba.Endpoint.Title}*/} {anthropicConfigComponent}
{/* subTitle={*/} {baiduConfigComponent}
{/* Locale.Settings.Access.Alibaba.Endpoint.SubTitle +*/} {byteDanceConfigComponent}
{/* Alibaba.ExampleEndpoint*/} {alibabaConfigComponent}
{/* }*/} </>
{/* >*/} )}
{/* <input*/} </>
{/* type="text"*/} )}
{/* value={accessStore.alibabaUrl}*/} -->
{/* placeholder={Alibaba.ExampleEndpoint}*/} <!--
{/* onChange={(e) =>*/} {!shouldHideBalanceQuery && !clientConfig?.isApp ? (
{/* accessStore.update(*/} <ListItem
{/* (access) =>*/} title={Locale.Settings.Usage.Title}
{/* (access.alibabaUrl = e.currentTarget.value),*/} subTitle={
{/* )*/} showUsage
{/* }*/} ? loadingUsage
{/* ></input>*/} ? Locale.Settings.Usage.IsChecking
{/* </ListItem>*/} : Locale.Settings.Usage.SubTitle(
{/* <ListItem*/} usage?.used ?? "[?]",
{/* title={Locale.Settings.Access.Alibaba.ApiKey.Title}*/} usage?.subscription ?? "[?]",
{/* subTitle={*/} )
{/* Locale.Settings.Access.Alibaba.ApiKey.SubTitle*/} : Locale.Settings.Usage.NoAccess
{/* }*/} }
{/* >*/} >
{/* <PasswordInput*/} {!showUsage || loadingUsage ? (
{/* value={accessStore.alibabaApiKey}*/} <div />
{/* type="text"*/} ) : (
{/* placeholder={*/} <IconButton
{/* Locale.Settings.Access.Alibaba.ApiKey.Placeholder*/} icon={<ResetIcon></ResetIcon>}
{/* }*/} text={Locale.Settings.Usage.Check}
{/* onChange={(e) => {*/} onClick={() => checkUsage(true)}
{/* accessStore.update(*/} />
{/* (access) =>*/} )}
{/* (access.alibabaApiKey = e.currentTarget.value),*/} </ListItem>
{/* );*/} ) : null}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* </>*/}
{/* )}*/}
{/* </>*/}
{/* )}*/}
{/* </>*/}
{/*)}*/}
{/*{!shouldHideBalanceQuery && !clientConfig?.isApp ? (*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Usage.Title}*/}
{/* subTitle={*/}
{/* showUsage*/}
{/* ? loadingUsage*/}
{/* ? Locale.Settings.Usage.IsChecking*/}
{/* : Locale.Settings.Usage.SubTitle(*/}
{/* usage?.used ?? "[?]",*/}
{/* usage?.subscription ?? "[?]",*/}
{/* )*/}
{/* : Locale.Settings.Usage.NoAccess*/}
{/* }*/}
{/* >*/}
{/* {!showUsage || loadingUsage ? (*/}
{/* <div />*/}
{/* ) : (*/}
{/* <IconButton*/}
{/* icon={<ResetIcon></ResetIcon>}*/}
{/* text={Locale.Settings.Usage.Check}*/}
{/* onClick={() => checkUsage(true)}*/}
{/* />*/}
{/* )}*/}
{/* </ListItem>*/}
{/*) : null}*/}
{/* /!*<ListItem*!/*/}
{/* /!* title={Locale.Settings.Access.CustomModel.Title}*!/*/}
{/* /!* subTitle={Locale.Settings.Access.CustomModel.SubTitle}*!/*/}
{/* /!*>*!/*/}
{/* /!* <input*!/*/}
{/* /!* type="text"*!/*/}
{/* /!* value={config.customModels}*!/*/}
{/* /!* placeholder="model1,model2,model3"*!/*/}
{/* /!* onChange={(e) =>*!/*/}
{/* /!* config.update(*!/*/}
{/* /!* (config) => (config.customModels = e.currentTarget.value),*!/*/}
{/* /!* )*!/*/}
{/* /!* }*!/*/}
{/* /!* ></input>*!/*/}
{/* /!*</ListItem>*!/*/}
{/*</List>*/}
<ListItem
title={Locale.Settings.Access.CustomModel.Title}
subTitle={Locale.Settings.Access.CustomModel.SubTitle}
>
<input
type="text"
value={config.customModels}
placeholder="model1,model2,model3"
onChange={(e) =>
config.update(
(config) => (config.customModels = e.currentTarget.value),
)
}
></input>
</ListItem>
</List>
-->
<List> <List>
<ModelConfigList <ModelConfigList
modelConfig={config.modelConfig} modelConfig={config.modelConfig}

View File

@ -91,6 +91,15 @@ export enum ServiceProvider {
Alibaba = "Alibaba", 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 { export enum ModelProvider {
GPT = "GPT", GPT = "GPT",
GeminiPro = "GeminiPro", GeminiPro = "GeminiPro",
@ -180,6 +189,7 @@ Latex inline: \\(x^2\\)
Latex block: $$e=mc^2$$ Latex block: $$e=mc^2$$
`; `;
// export const SUMMARIZE_MODEL = "gpt-4o-mini";
export const SUMMARIZE_MODEL = "gpt-4o"; export const SUMMARIZE_MODEL = "gpt-4o";
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro"; export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";

View File

@ -386,6 +386,10 @@ const cn = {
Title: "API 版本(仅适用于 gemini-pro", Title: "API 版本(仅适用于 gemini-pro",
SubTitle: "选择一个特定的 API 版本", SubTitle: "选择一个特定的 API 版本",
}, },
GoogleSafetySettings: {
Title: "Google 安全过滤级别",
SubTitle: "设置内容过滤级别",
},
}, },
Baidu: { Baidu: {
ApiKey: { ApiKey: {

View File

@ -432,6 +432,10 @@ const en: LocaleType = {
Title: "API Version (specific to gemini-pro)", Title: "API Version (specific to gemini-pro)",
SubTitle: "Select a specific API version", SubTitle: "Select a specific API version",
}, },
GoogleSafetySettings: {
Title: "Google Safety Settings",
SubTitle: "Select a safety filtering level",
},
}, },
}, },

View File

@ -1,6 +1,7 @@
import { import {
ApiPath, ApiPath,
DEFAULT_API_HOST, DEFAULT_API_HOST,
GoogleSafetySettingsThreshold,
ServiceProvider, ServiceProvider,
StoreKey, StoreKey,
} from "../constant"; } from "../constant";
@ -60,6 +61,7 @@ const DEFAULT_ACCESS_STATE = {
googleUrl: DEFAULT_GOOGLE_URL, googleUrl: DEFAULT_GOOGLE_URL,
googleApiKey: "", googleApiKey: "",
googleApiVersion: "v1", googleApiVersion: "v1",
googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH,
// anthropic // anthropic
anthropicUrl: DEFAULT_ANTHROPIC_URL, anthropicUrl: DEFAULT_ANTHROPIC_URL,

View File

@ -95,6 +95,7 @@ function createEmptySession(): ChatSession {
}; };
} }
// if it is using gpt-* models, force to use 4o-mini to summarize
const ChatFetchTaskPool: Record<string, any> = {}; const ChatFetchTaskPool: Record<string, any> = {};
function getSummarizeModel(currentModel: string): { function getSummarizeModel(currentModel: string): {

View File

@ -9,7 +9,7 @@
}, },
"package": { "package": {
"productName": "NextChat", "productName": "NextChat",
"version": "2.13.0" "version": "2.13.1"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {