mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 02:40:14 +01:00
feat: Order/disable endpoints with ENDPOINTS env var (#1206)
* fix: endpoint will not be select if disabled * feat: order and disable endpoints with ENDPOINTS env var * chore: remove console.log
This commit is contained in:
parent
f05f6826f5
commit
f3402401f1
6 changed files with 66 additions and 33 deletions
|
|
@ -1,22 +1,11 @@
|
|||
import type { TConversation, TPreset, TEndpointsConfig } from 'librechat-data-provider';
|
||||
import { EModelEndpoint } from 'librechat-data-provider';
|
||||
import getLocalStorageItems from './getLocalStorageItems';
|
||||
import mapEndpoints from './mapEndpoints';
|
||||
|
||||
type TConvoSetup = Partial<TPreset> | Partial<TConversation>;
|
||||
|
||||
type TDefaultEndpoint = { convoSetup: TConvoSetup; endpointsConfig: TEndpointsConfig };
|
||||
|
||||
export const defaultEndpoints: EModelEndpoint[] = [
|
||||
EModelEndpoint.openAI,
|
||||
EModelEndpoint.assistant,
|
||||
EModelEndpoint.azureOpenAI,
|
||||
EModelEndpoint.bingAI,
|
||||
EModelEndpoint.chatGPTBrowser,
|
||||
EModelEndpoint.gptPlugins,
|
||||
EModelEndpoint.google,
|
||||
EModelEndpoint.anthropic,
|
||||
];
|
||||
|
||||
const getEndpointFromSetup = (convoSetup: TConvoSetup, endpointsConfig: TEndpointsConfig) => {
|
||||
const { endpoint: targetEndpoint } = convoSetup || {};
|
||||
if (targetEndpoint && endpointsConfig?.[targetEndpoint]) {
|
||||
|
|
@ -49,7 +38,8 @@ const getEndpointFromLocalStorage = (endpointsConfig: TEndpointsConfig) => {
|
|||
};
|
||||
|
||||
const getDefinedEndpoint = (endpointsConfig: TEndpointsConfig) => {
|
||||
return defaultEndpoints.find((e) => Object.hasOwn(endpointsConfig ?? {}, e)) ?? 'openAI';
|
||||
const endpoints = mapEndpoints(endpointsConfig);
|
||||
return endpoints.find((e) => Object.hasOwn(endpointsConfig ?? {}, e));
|
||||
};
|
||||
|
||||
const getDefaultEndpoint = ({ convoSetup, endpointsConfig }: TDefaultEndpoint) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue