mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20: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
|
|
@ -4,9 +4,9 @@ import { alternateName } from 'librechat-data-provider';
|
|||
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
|
||||
import { DropdownMenuRadioItem } from '~/components';
|
||||
import { SetKeyDialog } from '../SetKeyDialog';
|
||||
import { cn, getEndpointField } from '~/utils';
|
||||
import { Icon } from '~/components/Endpoints';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
export default function ModelItem({
|
||||
endpoint,
|
||||
|
|
@ -29,7 +29,11 @@ export default function ModelItem({
|
|||
isCreatedByUser: false,
|
||||
});
|
||||
|
||||
const userProvidesKey = endpointsConfig?.[endpoint]?.userProvide;
|
||||
const userProvidesKey: boolean | null | undefined = getEndpointField(
|
||||
endpointsConfig,
|
||||
endpoint,
|
||||
'userProvide',
|
||||
);
|
||||
const localize = useLocalize();
|
||||
|
||||
// regular model
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import React, { useEffect, useContext, useRef, useState, useCallback } from 'react';
|
||||
import TextareaAutosize from 'react-textarea-autosize';
|
||||
import { useRecoilValue, useRecoilState, useSetRecoilState } from 'recoil';
|
||||
import SubmitButton from './SubmitButton';
|
||||
import React, { useEffect, useContext, useRef, useState, useCallback } from 'react';
|
||||
|
||||
import OptionsBar from './OptionsBar';
|
||||
import { EndpointMenu } from './EndpointMenu';
|
||||
import SubmitButton from './SubmitButton';
|
||||
import OptionsBar from './OptionsBar';
|
||||
import Footer from './Footer';
|
||||
|
||||
import { useMessageHandler, ThemeContext } from '~/hooks';
|
||||
import { cn } from '~/utils';
|
||||
import { cn, getEndpointField } from '~/utils';
|
||||
import store from '~/store';
|
||||
|
||||
interface TextChatProps {
|
||||
|
|
@ -195,7 +196,7 @@ export default function TextChat({ isSearchView = false }: TextChatProps) {
|
|||
isSubmitting={isSubmitting}
|
||||
userProvidesKey={
|
||||
conversation?.endpoint
|
||||
? endpointsConfig?.[conversation.endpoint]?.userProvide
|
||||
? getEndpointField(endpointsConfig, conversation.endpoint, 'userProvide')
|
||||
: undefined
|
||||
}
|
||||
hasText={hasText}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue