mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 19:30:15 +01:00
refactor: update imports to use normalizeEndpointName from @librechat/api and remove redundant definitions
This commit is contained in:
parent
8df0ecd438
commit
5e70d518aa
6 changed files with 17 additions and 18 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
const { logger } = require('@librechat/data-schemas');
|
const { logger } = require('@librechat/data-schemas');
|
||||||
const { isEnabled, getUserMCPAuthMap } = require('@librechat/api');
|
const { isEnabled, getUserMCPAuthMap, normalizeEndpointName } = require('@librechat/api');
|
||||||
const { CacheKeys, EModelEndpoint } = require('librechat-data-provider');
|
const { CacheKeys, EModelEndpoint } = require('librechat-data-provider');
|
||||||
const { normalizeEndpointName } = require('~/server/utils');
|
|
||||||
const loadCustomConfig = require('./loadCustomConfig');
|
const loadCustomConfig = require('./loadCustomConfig');
|
||||||
const getLogStores = require('~/cache/getLogStores');
|
const getLogStores = require('~/cache/getLogStores');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
const { isUserProvided, normalizeEndpointName } = require('@librechat/api');
|
||||||
const { EModelEndpoint, extractEnvVariable } = require('librechat-data-provider');
|
const { EModelEndpoint, extractEnvVariable } = require('librechat-data-provider');
|
||||||
const { isUserProvided, normalizeEndpointName } = require('~/server/utils');
|
|
||||||
const { getCustomConfig } = require('./getCustomConfig');
|
const { getCustomConfig } = require('./getCustomConfig');
|
||||||
const { getAppConfig } = require('./app');
|
const { getAppConfig } = require('./app');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
const { isUserProvided, normalizeEndpointName } = require('@librechat/api');
|
||||||
const { EModelEndpoint, extractEnvVariable } = require('librechat-data-provider');
|
const { EModelEndpoint, extractEnvVariable } = require('librechat-data-provider');
|
||||||
const { isUserProvided, normalizeEndpointName } = require('~/server/utils');
|
|
||||||
const { fetchModels } = require('~/server/services/ModelService');
|
const { fetchModels } = require('~/server/services/ModelService');
|
||||||
const { getCustomConfig } = require('./getCustomConfig');
|
const { getCustomConfig } = require('./getCustomConfig');
|
||||||
const { getAppConfig } = require('./app');
|
const { getAppConfig } = require('./app');
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
const { logger } = require('@librechat/data-schemas');
|
||||||
|
const { normalizeEndpointName } = require('@librechat/api');
|
||||||
const { EModelEndpoint } = require('librechat-data-provider');
|
const { EModelEndpoint } = require('librechat-data-provider');
|
||||||
const { normalizeEndpointName } = require('~/server/utils');
|
|
||||||
const { logger } = require('~/config');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up Model Specs from the config (`librechat.yaml`) file.
|
* Sets up Model Specs from the config (`librechat.yaml`) file.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ const {
|
||||||
defaultAgentCapabilities,
|
defaultAgentCapabilities,
|
||||||
} = require('librechat-data-provider');
|
} = require('librechat-data-provider');
|
||||||
const { sendEvent } = require('@librechat/api');
|
const { sendEvent } = require('@librechat/api');
|
||||||
const { Providers } = require('@librechat/agents');
|
|
||||||
const partialRight = require('lodash/partialRight');
|
const partialRight = require('lodash/partialRight');
|
||||||
|
|
||||||
/** Helper function to escape special characters in regex
|
/** Helper function to escape special characters in regex
|
||||||
|
|
@ -207,15 +206,6 @@ function generateConfig(key, baseURL, endpoint) {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize the endpoint name to system-expected value.
|
|
||||||
* @param {string} name
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function normalizeEndpointName(name = '') {
|
|
||||||
return name.toLowerCase() === Providers.OLLAMA ? Providers.OLLAMA : name;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isEnabled,
|
isEnabled,
|
||||||
handleText,
|
handleText,
|
||||||
|
|
@ -226,5 +216,4 @@ module.exports = {
|
||||||
generateConfig,
|
generateConfig,
|
||||||
addSpaceIfNeeded,
|
addSpaceIfNeeded,
|
||||||
createOnProgress,
|
createOnProgress,
|
||||||
normalizeEndpointName,
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
import { Providers } from '@librechat/agents';
|
||||||
|
import { AuthType } from 'librechat-data-provider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given value is truthy by being either the boolean `true` or a string
|
* Checks if the given value is truthy by being either the boolean `true` or a string
|
||||||
* that case-insensitively matches 'true'.
|
* that case-insensitively matches 'true'.
|
||||||
|
|
@ -31,7 +34,7 @@ export function isEnabled(value?: string | boolean | null | undefined): boolean
|
||||||
* @param value - The value to check.
|
* @param value - The value to check.
|
||||||
* @returns - Returns true if the value is 'user_provided', otherwise false.
|
* @returns - Returns true if the value is 'user_provided', otherwise false.
|
||||||
*/
|
*/
|
||||||
export const isUserProvided = (value?: string): boolean => value === 'user_provided';
|
export const isUserProvided = (value?: string): boolean => value === AuthType.USER_PROVIDED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param values
|
* @param values
|
||||||
|
|
@ -46,3 +49,11 @@ export function optionalChainWithEmptyCheck(
|
||||||
}
|
}
|
||||||
return values[values.length - 1];
|
return values[values.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize the endpoint name to system-expected value.
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
export function normalizeEndpointName(name = ''): string {
|
||||||
|
return name.toLowerCase() === Providers.OLLAMA ? Providers.OLLAMA : name;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue