diff --git a/react-native/src/api/open-api.ts b/react-native/src/api/open-api.ts index e8b0912..45ce8dc 100644 --- a/react-native/src/api/open-api.ts +++ b/react-native/src/api/open-api.ts @@ -3,7 +3,7 @@ import { getApiUrl, getDeepSeekApiKey, getOpenAIApiKey, - getServerProxyEnabled, + getOpenAIProxyEnabled, getTextModel, } from '../storage/StorageUtils.ts'; import { @@ -260,7 +260,7 @@ function getApiURL(): string { if (getTextModel().modelId.includes('deepseek')) { return 'https://api.deepseek.com/chat/completions'; } else { - if (getServerProxyEnabled()) { + if (getOpenAIProxyEnabled()) { return (isDev ? 'http://localhost:8080' : getApiUrl()) + '/api/gpt'; } else { return 'https://api.openai.com/v1/chat/completions'; diff --git a/react-native/src/settings/SettingsScreen.tsx b/react-native/src/settings/SettingsScreen.tsx index 4b2a518..7d66613 100644 --- a/react-native/src/settings/SettingsScreen.tsx +++ b/react-native/src/settings/SettingsScreen.tsx @@ -27,6 +27,7 @@ import { getModelUsage, getOllamaApiUrl, getOpenAIApiKey, + getOpenAIProxyEnabled, getRegion, getTextModel, isNewStabilityImageModel, @@ -37,6 +38,7 @@ import { saveKeys, saveOllamaApiURL, saveOpenAIApiKey, + saveOpenAIProxyEnabled, saveRegion, saveTextModel, } from '../storage/StorageUtils.ts'; @@ -73,6 +75,9 @@ function SettingsScreen(): React.JSX.Element { const [ollamaApiUrl, setOllamaApiUrl] = useState(getOllamaApiUrl); const [deepSeekApiKey, setDeepSeekApiKey] = useState(getDeepSeekApiKey); const [openAIApiKey, setOpenAIApiKey] = useState(getOpenAIApiKey); + const [openAIProxyEnabled, setOpenAIProxyEnabled] = useState( + getOpenAIProxyEnabled + ); const [region, setRegion] = useState(getRegion); const [imageSize, setImageSize] = useState(getImageSize); const [hapticEnabled, setHapticEnabled] = useState(getHapticEnabled); @@ -238,6 +243,11 @@ function SettingsScreen(): React.JSX.Element { value: size, })); + const toggleOpenAIProxy = (value: boolean) => { + setOpenAIProxyEnabled(value); + saveOpenAIProxyEnabled(value); + }; + return ( @@ -277,13 +287,6 @@ function SettingsScreen(): React.JSX.Element { onChangeText={setOllamaApiUrl} placeholder="Enter Ollama API URL" /> - + + + + + + Proxy + + + Select Model