Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

feat: return endpoint config from server

Wentao Lyu60be4f12b705
diff --git a/api/server/index.js b/api/server/index.js
index 6af81329c0..d70c13839c 100644
--- a/api/server/index.js
+++ b/api/server/index.js
@@ -62,7 +62,9 @@ const projectPath = path.join(__dirname, '..', '..', 'client');
app.get('/api/endpoints', function (req, res) {
const azureOpenAI = !!process.env.AZURE_OPENAI_KEY;
- const openAI = !!process.env.OPENAI_KEY;
+ const openAI = process.env.OPENAI_KEY
+ ? { availableModels: ['gpt-4', 'text-davinci-003', 'gpt-3.5-turbo', 'gpt-3.5-turbo-0301'] }
+ : false;
const bingAI = !!process.env.BING_TOKEN;
const chatGPTBrowser = !!process.env.CHATGPT_TOKEN;
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 91a49e2efa..d5df7345cc 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -38,7 +38,7 @@ const router = createBrowserRouter([
const App = () => {
const [user, setUser] = useRecoilState(store.user);
const setIsSearchEnabled = useSetRecoilState(store.isSearchEnabled);
- const setEndpointsFilter = useSetRecoilState(store.endpointsFilter);
+ const setEndpointsConfig = useSetRecoilState(store.endpointsConfig);
useEffect(() => {
// fetch if seatch enabled
@@ -63,7 +63,7 @@ const App = () => {
withCredentials: true
})
.then(({ data }) => {
- setEndpointsFilter(data);
+ setEndpointsConfig(data);
})
.catch(error => {
console.error(error);
diff --git a/client/src/components/Input/OpenAIOptions/ModelSelect.jsx b/client/src/components/Input/OpenAIOptions/ModelSelect.jsx
index 73e2a7303b..6ae9520f04 100644
--- a/client/src/components/Input/OpenAIOptions/ModelSelect.jsx
+++ b/client/src/components/Input/OpenAIOptions/ModelSelect.jsx
@@ -10,11 +10,9 @@ import {
DropdownMenuRadioItem
} from '../../ui/DropdownMenu.tsx';
-const ModelSelect = ({ model, onChange, models, ...props }) => {
+const ModelSelect = ({ model, onChange, availableModels, ...props }) => {
const [menuOpen, setMenuOpen] = useState(false);
- models = ['gpt-4', 'text-davinci-003', 'gpt-3.5-turbo', 'gpt-3.5-turbo-0301'];
-
return (
<DropdownMenu
open={menuOpen}
@@ -36,7 +34,7 @@ const ModelSelect = ({ model, onChange, models, ...props }) => {
onValueChange={onChange}
className="overflow-y-auto"
>
- {models.map(model => (
+ {availableModels.map(model => (
<DropdownMenuRadioItem
key={model}
value={model}
diff --git a/client/src/store/endpoints.js b/client/src/store/endpoints.js
index e4f10ce195..2406e461cd 100644
--- a/client/src/store/endpoints.js
+++ b/client/src/store/endpoints.js
@@ -1,12 +1,23 @@
import { atom, selector } from 'recoil';
-const endpointsFilter = atom({
- key: 'endpointsFilter',
+const endpointsConfig = atom({
+ key: 'endpointsConfig',
default: {
- azureOpenAI: false,
- openAI: false,
- bingAI: false,
- chatGPTBrowser: false
+ azureOpenAI: null,
+ openAI: null,
+ bingAI: null,
+ chatGPTBrowser: null
+ }
+});
+
+const endpointsFilter = selector({
+ key: 'endpointsFilter',
+ get: ({ get }) => {
+ const config = get(endpointsConfig) || {};
+
+ let filter = {};
+ for (const key of Object.keys(config)) filter[key] = !!config[key];
+ return filter;
}
});
@@ -21,6 +32,7 @@ const availableEndpoints = selector({
// const modelAvailable
export default {
+ endpointsConfig,
endpointsFilter,
availableEndpoints
};