mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
feat: return endpoint config from server
This commit is contained in:
parent
b687ab30ed
commit
60be4f12b7
4 changed files with 25 additions and 13 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue