mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
🔄 refactor(EditPresetDialog): Update Model on Endpoint Change (#2936)
* refactor(EditPresetDialog): dynamically update current editable preset model on endpoint change * feat: Add null check for models in EditPresetDialog * chore(AlertDialogPortal): typing * fix(EditPresetDialog): prevent Unknown endpoint edge case for custom endpoints
This commit is contained in:
parent
248dfb8b5b
commit
f9a0166352
5 changed files with 98 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import type { TPreset, TPlugin } from 'librechat-data-provider';
|
||||
import type { TSetOptionsPayload, TSetExample, TSetOption } from '~/common';
|
||||
import type { TSetOptionsPayload, TSetExample, TSetOption, TSetOptions } from '~/common';
|
||||
import { useChatContext } from '~/Providers/ChatContext';
|
||||
import { cleanupPreset } from '~/utils';
|
||||
import store from '~/store';
|
||||
|
|
@ -17,6 +17,18 @@ const usePresetIndexOptions: TUsePresetOptions = (_preset) => {
|
|||
}
|
||||
const getConversation: () => TPreset | null = () => preset;
|
||||
|
||||
const setOptions: TSetOptions = (options) => {
|
||||
const update = { ...options };
|
||||
setPreset((prevState) =>
|
||||
cleanupPreset({
|
||||
preset: {
|
||||
...prevState,
|
||||
...update,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const setOption: TSetOption = (param) => (newValue) => {
|
||||
const update = {};
|
||||
update[param] = newValue;
|
||||
|
|
@ -155,6 +167,7 @@ const usePresetIndexOptions: TUsePresetOptions = (_preset) => {
|
|||
setOption,
|
||||
setExample,
|
||||
addExample,
|
||||
setOptions,
|
||||
removeExample,
|
||||
getConversation,
|
||||
checkPluginSelection,
|
||||
|
|
|
|||
|
|
@ -157,13 +157,13 @@ const useSetIndexOptions: TUseSetOptions = (preset = false) => {
|
|||
};
|
||||
|
||||
return {
|
||||
setTools,
|
||||
setOption,
|
||||
setExample,
|
||||
addExample,
|
||||
removeExample,
|
||||
setAgentOption,
|
||||
checkPluginSelection,
|
||||
setTools,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue