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 2152ab397..f42306750 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, @@ -657,6 +658,389 @@ export function Settings() { const clientConfig = useMemo(() => getClientConfig(), []); const showAccessCode = enabledAccessControl && !clientConfig?.isApp; + const accessCodeComponent = showAccessCode && ( + + { + accessStore.update( + (access) => (access.accessCode = e.currentTarget.value), + ); + }} + /> + + ); + + const useCustomConfigComponent = // Conditionally render the following ListItem based on clientConfig.isApp + !clientConfig?.isApp && ( // only show if isApp is false + + + accessStore.update( + (access) => (access.useCustomConfig = e.currentTarget.checked), + ) + } + > + + ); + + const openAIConfigComponent = accessStore.provider === + ServiceProvider.OpenAI && ( + <> + + + accessStore.update( + (access) => (access.openaiUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.openaiApiKey = e.currentTarget.value), + ); + }} + /> + + + ); + + const azureConfigComponent = accessStore.provider === + ServiceProvider.Azure && ( + <> + + + accessStore.update( + (access) => (access.azureUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.azureApiKey = e.currentTarget.value), + ); + }} + /> + + + + accessStore.update( + (access) => (access.azureApiVersion = e.currentTarget.value), + ) + } + > + + + ); + + const googleConfigComponent = accessStore.provider === + ServiceProvider.Google && ( + <> + + + accessStore.update( + (access) => (access.googleUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.googleApiKey = e.currentTarget.value), + ); + }} + /> + + + + accessStore.update( + (access) => (access.googleApiVersion = e.currentTarget.value), + ) + } + > + + + + + + ); + + const anthropicConfigComponent = accessStore.provider === + ServiceProvider.Anthropic && ( + <> + + + accessStore.update( + (access) => (access.anthropicUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.anthropicApiKey = e.currentTarget.value), + ); + }} + /> + + + + accessStore.update( + (access) => (access.anthropicApiVersion = e.currentTarget.value), + ) + } + > + + + ); + + const baiduConfigComponent = accessStore.provider === + ServiceProvider.Baidu && ( + <> + + + accessStore.update( + (access) => (access.baiduUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.baiduApiKey = e.currentTarget.value), + ); + }} + /> + + + { + accessStore.update( + (access) => (access.baiduSecretKey = e.currentTarget.value), + ); + }} + /> + + + ); + + const byteDanceConfigComponent = accessStore.provider === + ServiceProvider.ByteDance && ( + <> + + + accessStore.update( + (access) => (access.bytedanceUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.bytedanceApiKey = e.currentTarget.value), + ); + }} + /> + + + ); + + const alibabaConfigComponent = accessStore.provider === + ServiceProvider.Alibaba && ( + <> + + + accessStore.update( + (access) => (access.alibabaUrl = e.currentTarget.value), + ) + } + > + + + { + accessStore.update( + (access) => (access.alibabaApiKey = e.currentTarget.value), + ); + }} + /> + + + ); + return (
@@ -902,491 +1286,95 @@ export function Settings() { - {/**/} - {/* {showAccessCode && (*/} - {/* */} - {/* {*/} - {/* accessStore.update(*/} - {/* (access) => (access.accessCode = e.currentTarget.value),*/} - {/* );*/} - {/* }}*/} - {/* />*/} - {/* */} - {/* )}*/} + + = {}; function getSummarizeModel(currentModel: string): { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f20bfbb74..86faf4c3c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ }, "package": { "productName": "NextChat", - "version": "2.13.0" + "version": "2.13.1" }, "tauri": { "allowlist": {