mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
🔧 fix: Model Key Retrieval to Account for Bedrock Regions (#5029)
* 🔧 fix: model key retrieval logic to account for Bedrock region
* fix: edit preset dialog styling and potential max depth error with agents endpoint
This commit is contained in:
parent
d3cafeee96
commit
649c7a6032
5 changed files with 46 additions and 23 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { useRecoilState } from 'recoil';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { QueryKeys } from 'librechat-data-provider';
|
||||
import { QueryKeys, isAgentsEndpoint } from 'librechat-data-provider';
|
||||
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
|
||||
import type { TModelsConfig, TEndpointsConfig } from 'librechat-data-provider';
|
||||
import {
|
||||
|
|
@ -37,15 +37,26 @@ const EditPresetDialog = ({
|
|||
});
|
||||
const [presetModalVisible, setPresetModalVisible] = useRecoilState(store.presetModalVisible);
|
||||
|
||||
const { data: availableEndpoints = [] } = useGetEndpointsQuery({
|
||||
const { data: _endpoints = [] } = useGetEndpointsQuery({
|
||||
select: mapEndpoints,
|
||||
});
|
||||
|
||||
const availableEndpoints = useMemo(() => {
|
||||
return _endpoints.filter((endpoint) => !isAgentsEndpoint(endpoint));
|
||||
}, [_endpoints]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!preset) {
|
||||
return;
|
||||
}
|
||||
if (!preset.endpoint) {
|
||||
|
||||
if (isAgentsEndpoint(preset.endpoint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const presetEndpoint = preset.endpoint ?? '';
|
||||
|
||||
if (!presetEndpoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +65,7 @@ const EditPresetDialog = ({
|
|||
return;
|
||||
}
|
||||
|
||||
const models = modelsConfig[preset.endpoint];
|
||||
const models = modelsConfig[presetEndpoint] as string[] | undefined;
|
||||
if (!models) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -75,7 +86,11 @@ const EditPresetDialog = ({
|
|||
return;
|
||||
}
|
||||
|
||||
if (preset.agentOptions?.model && !models.includes(preset.agentOptions.model)) {
|
||||
if (
|
||||
preset.agentOptions?.model != null &&
|
||||
preset.agentOptions.model &&
|
||||
!models.includes(preset.agentOptions.model)
|
||||
) {
|
||||
console.log('setting agent model', models[0]);
|
||||
setAgentOption('model')(models[0]);
|
||||
}
|
||||
|
|
@ -102,9 +117,12 @@ const EditPresetDialog = ({
|
|||
[queryClient, setOptions],
|
||||
);
|
||||
|
||||
const { endpoint, endpointType, model } = preset || {};
|
||||
const { endpoint: _endpoint, endpointType, model } = preset || {};
|
||||
const endpoint = _endpoint ?? '';
|
||||
if (!endpoint) {
|
||||
return null;
|
||||
} else if (isAgentsEndpoint(endpoint)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -121,7 +139,7 @@ const EditPresetDialog = ({
|
|||
title={`${localize('com_ui_edit') + ' ' + localize('com_endpoint_preset')} - ${
|
||||
preset?.title
|
||||
}`}
|
||||
className="h-full max-w-full overflow-y-auto pb-4 sm:w-[680px] sm:pb-0 md:h-[720px] md:w-[750px] md:overflow-y-hidden md:overflow-y-hidden lg:w-[950px] xl:h-[720px]"
|
||||
className="h-full max-w-full overflow-y-auto pb-4 sm:w-[680px] sm:pb-0 md:h-[720px] md:w-[750px] md:overflow-y-hidden lg:w-[950px] xl:h-[720px]"
|
||||
main={
|
||||
<div className="flex w-full flex-col items-center gap-2 md:h-[550px] md:overflow-y-auto">
|
||||
<div className="grid w-full">
|
||||
|
|
@ -165,7 +183,7 @@ const EditPresetDialog = ({
|
|||
{'ㅤ'}
|
||||
</Label>
|
||||
<PopoverButtons
|
||||
buttonClass="ml-0 w-full border border-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-600 p-2 h-[40px] justify-center mt-0"
|
||||
buttonClass="ml-0 w-full border border-border-medium p-2 h-[40px] justify-center mt-0"
|
||||
iconClass="hidden lg:block w-4 "
|
||||
endpoint={endpoint}
|
||||
endpointType={endpointType}
|
||||
|
|
@ -174,13 +192,13 @@ const EditPresetDialog = ({
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="my-4 w-full border-t border-gray-300 dark:border-gray-600" />
|
||||
<div className="my-4 w-full border-t border-border-medium" />
|
||||
<div className="w-full p-0">
|
||||
<EndpointSettings
|
||||
conversation={preset}
|
||||
setOption={setOption}
|
||||
isPreset={true}
|
||||
className="h-full md:mb-4 md:h-[440px]"
|
||||
className="h-full text-text-primary md:mb-4 md:h-[440px]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue