mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 01:40:15 +01:00
🔧 fix: Improve Endpoint Handling and Address Edge Cases (#1486)
* fix(TEndpointsConfig): resolve property access issues with typesafe helper function * fix: undefined or null endpoint edge case * refactor(mapEndpoints -> endpoints): renamed module to be more general for endpoint handling, wrote unit tests, export all helpers
This commit is contained in:
parent
42f2353509
commit
9864fc8700
24 changed files with 275 additions and 99 deletions
|
|
@ -13,11 +13,11 @@ import {
|
|||
} from '~/data-provider';
|
||||
import { useChatContext, useToastContext } from '~/Providers';
|
||||
import useNavigateToConvo from '~/hooks/useNavigateToConvo';
|
||||
import { cleanupPreset, getEndpointField } from '~/utils';
|
||||
import useDefaultConvo from '~/hooks/useDefaultConvo';
|
||||
import { useAuthContext } from '~/hooks/AuthContext';
|
||||
import { NotificationSeverity } from '~/common';
|
||||
import useLocalize from '~/hooks/useLocalize';
|
||||
import { cleanupPreset } from '~/utils';
|
||||
import store from '~/store';
|
||||
|
||||
export default function usePresets() {
|
||||
|
|
@ -162,12 +162,13 @@ export default function usePresets() {
|
|||
|
||||
const endpointsConfig = queryClient.getQueryData<TEndpointsConfig>([QueryKeys.endpoints]);
|
||||
|
||||
const currentEndpointType = endpointsConfig?.[endpoint ?? '']?.type ?? '';
|
||||
const endpointType = endpointsConfig?.[newPreset?.endpoint ?? '']?.type;
|
||||
const currentEndpointType = getEndpointField(endpointsConfig, endpoint, 'type');
|
||||
const endpointType = getEndpointField(endpointsConfig, newPreset.endpoint, 'type');
|
||||
|
||||
if (
|
||||
(modularEndpoints.has(endpoint ?? '') || modularEndpoints.has(currentEndpointType)) &&
|
||||
(modularEndpoints.has(newPreset?.endpoint ?? '') || modularEndpoints.has(endpointType)) &&
|
||||
(modularEndpoints.has(endpoint ?? '') || modularEndpoints.has(currentEndpointType ?? '')) &&
|
||||
(modularEndpoints.has(newPreset?.endpoint ?? '') ||
|
||||
modularEndpoints.has(endpointType ?? '')) &&
|
||||
(endpoint === newPreset?.endpoint || modularChat)
|
||||
) {
|
||||
const currentConvo = getDefaultConversation({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue