import { useMemo } from "react"; import { Anthropic, Azure, Google, OPENAI_BASE_URL, ServiceProvider, SlotID, } from "@/app/constant"; import Locale from "@/app/locales"; import { useAccessStore } from "@/app/store/access"; import { getClientConfig } from "@/app/config/client"; import { useAppConfig } from "@/app/store/config"; import List, { ListItem } from "@/app/components/List"; import Select from "@/app/components/Select"; import Switch from "@/app/components/Switch"; import Input from "@/app/components/Input"; export default function ProviderSetting() { const accessStore = useAccessStore(); const config = useAppConfig(); const { isMobileScreen } = config; const clientConfig = useMemo(() => getClientConfig(), []); return ( {!accessStore.hideUserApiKey && ( <> { // Conditionally render the following ListItem based on clientConfig.isApp !clientConfig?.isApp && ( // only show if isApp is false accessStore.update((access) => (access.useCustomConfig = e)) } /> ) } {accessStore.useCustomConfig && ( <> accessStore.update((access) => (access.openaiUrl = e)) } > { accessStore.update( (access) => (access.openaiApiKey = e), ); }} /> )} {accessStore.provider === ServiceProvider.Azure && ( <> accessStore.update((access) => (access.azureUrl = e)) } > { accessStore.update( (access) => (access.azureApiKey = e), ); }} /> accessStore.update( (access) => (access.azureApiVersion = e), ) } > )} {accessStore.provider === ServiceProvider.Google && ( <> accessStore.update((access) => (access.googleUrl = e)) } > { accessStore.update( (access) => (access.googleApiKey = e), ); }} /> accessStore.update( (access) => (access.googleApiVersion = e), ) } > )} {accessStore.provider === ServiceProvider.Anthropic && ( <> accessStore.update( (access) => (access.anthropicUrl = e), ) } > { accessStore.update( (access) => (access.anthropicApiKey = e), ); }} /> accessStore.update( (access) => (access.anthropicApiVersion = e), ) } > )} )} )} config.update((config) => (config.customModels = e))} > ); }