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 ( { onValueChange={onChange} className="overflow-y-auto" > - {models.map(model => ( + {availableModels.map(model => ( { + 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 };