mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 20:00:15 +01:00
fix: ensure custom params are not passed to non custom models
This commit is contained in:
parent
6e32f71565
commit
796d8031e8
10 changed files with 503 additions and 151 deletions
|
|
@ -42,6 +42,8 @@ export default function Conversation({
|
|||
dispatch(setEmptyMessage());
|
||||
|
||||
const convo = { title, error: false, conversationId: id, chatGptLabel, promptPrefix };
|
||||
// debugging
|
||||
console.log(model, chatGptLabel, promptPrefix);
|
||||
|
||||
if (bingData) {
|
||||
const {
|
||||
|
|
@ -77,17 +79,19 @@ export default function Conversation({
|
|||
|
||||
if (chatGptLabel) {
|
||||
dispatch(setModel('chatgptCustom'));
|
||||
dispatch(setCustomModel(chatGptLabel.toLowerCase()));
|
||||
} else {
|
||||
dispatch(setModel(model));
|
||||
}
|
||||
|
||||
if (modelMap[model.toLowerCase()]) {
|
||||
console.log('sender', model);
|
||||
dispatch(setCustomModel(model.toLowerCase()));
|
||||
} else {
|
||||
dispatch(setCustomModel(null));
|
||||
}
|
||||
|
||||
// if (modelMap[chatGptLabel.toLowerCase()]) {
|
||||
// console.log('custom model', chatGptLabel);
|
||||
// dispatch(setCustomModel(chatGptLabel.toLowerCase()));
|
||||
// } else {
|
||||
// dispatch(setCustomModel(null));
|
||||
// }
|
||||
|
||||
dispatch(setMessages(data));
|
||||
dispatch(setCustomGpt(convo));
|
||||
dispatch(setText(''));
|
||||
|
|
|
|||
|
|
@ -46,7 +46,10 @@ export default function ModelMenu() {
|
|||
mutate();
|
||||
try {
|
||||
const lastSelected = JSON.parse(localStorage.getItem('model'));
|
||||
if (lastSelected && lastSelected !== 'chatgptCustom' && initial[lastSelected]) {
|
||||
|
||||
if (lastSelected === 'chatgptCustom') {
|
||||
return;
|
||||
} else if (initial[lastSelected]) {
|
||||
dispatch(setModel(lastSelected));
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
@ -72,6 +75,7 @@ export default function ModelMenu() {
|
|||
dispatch(setModel(value));
|
||||
dispatch(setDisabled(false));
|
||||
dispatch(setCustomModel(null));
|
||||
dispatch(setCustomGpt({ chatGptLabel: null, promptPrefix: null }));
|
||||
} else if (!initial[value]) {
|
||||
const chatGptLabel = modelMap[value]?.chatGptLabel;
|
||||
const promptPrefix = modelMap[value]?.promptPrefix;
|
||||
|
|
|
|||
|
|
@ -11,22 +11,23 @@ import { increasePage, decreasePage, setPage, setConvos, setPages } from '~/stor
|
|||
export default function Nav({ navVisible, setNavVisible }) {
|
||||
const dispatch = useDispatch();
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const { conversationId, convos, pages, pageNumber, refreshConvoHint } = useSelector((state) => state.convo);
|
||||
const { conversationId, convos, pages, pageNumber, refreshConvoHint } = useSelector(
|
||||
(state) => state.convo
|
||||
);
|
||||
const onSuccess = (data) => {
|
||||
const { conversations, pages } = data;
|
||||
|
||||
if (pageNumber > pages)
|
||||
if (pageNumber > pages) {
|
||||
dispatch(setPage(pages));
|
||||
else
|
||||
} else {
|
||||
dispatch(setConvos(conversations));
|
||||
dispatch(setPages(pages));
|
||||
dispatch(setPages(pages));
|
||||
}
|
||||
};
|
||||
|
||||
const { data, isLoading, mutate } = swr(
|
||||
`/api/convos?pageNumber=${pageNumber}`,
|
||||
onSuccess,
|
||||
{revalidateOnMount: false}
|
||||
);
|
||||
const { data, isLoading, mutate } = swr(`/api/convos?pageNumber=${pageNumber}`, onSuccess, {
|
||||
revalidateOnMount: false
|
||||
});
|
||||
|
||||
const containerRef = useRef(null);
|
||||
const scrollPositionRef = useRef(null);
|
||||
|
|
@ -36,23 +37,25 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
if (container) {
|
||||
scrollPositionRef.current = container.scrollTop;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const nextPage = async () => {
|
||||
moveToTop()
|
||||
moveToTop();
|
||||
|
||||
dispatch(increasePage());
|
||||
await mutate();
|
||||
};
|
||||
|
||||
const previousPage = async () => {
|
||||
moveToTop()
|
||||
|
||||
moveToTop();
|
||||
|
||||
dispatch(decreasePage());
|
||||
await mutate();
|
||||
};
|
||||
|
||||
useEffect(() => {mutate()}, [pageNumber, conversationId, refreshConvoHint]);
|
||||
useEffect(() => {
|
||||
mutate();
|
||||
}, [pageNumber, conversationId, refreshConvoHint]);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
|
|
@ -66,14 +69,14 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
}, [data]);
|
||||
|
||||
useEffect(() => {
|
||||
setNavVisible(false)
|
||||
}, [conversationId, ])
|
||||
setNavVisible(false);
|
||||
}, [conversationId]);
|
||||
|
||||
const toggleNavVisible = () => {
|
||||
setNavVisible((prev) => {
|
||||
return !prev
|
||||
})
|
||||
}
|
||||
return !prev;
|
||||
});
|
||||
};
|
||||
|
||||
const containerClasses =
|
||||
isLoading && pageNumber === 1
|
||||
|
|
@ -82,7 +85,12 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<div className={"dark nav bg-gray-900 md:fixed md:inset-y-0 md:flex md:w-[260px] md:flex-col" + (navVisible?' active':'')}>
|
||||
<div
|
||||
className={
|
||||
'nav dark bg-gray-900 md:fixed md:inset-y-0 md:flex md:w-[260px] md:flex-col' +
|
||||
(navVisible ? ' active' : '')
|
||||
}
|
||||
>
|
||||
<div className="flex h-full min-h-0 flex-col ">
|
||||
<div className="scrollbar-trigger flex h-full w-full flex-1 items-start border-white/20">
|
||||
<nav className="flex h-full flex-1 flex-col space-y-1 p-2">
|
||||
|
|
@ -117,7 +125,7 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="nav-close-button -ml-0.5 -mt-0.5 inline-flex h-10 w-10 items-center justify-center rounded-md hover:text-gray-900 focus:outline-none focus:ring-white hover:text-white text-white"
|
||||
className="nav-close-button -ml-0.5 -mt-0.5 inline-flex h-10 w-10 items-center justify-center rounded-md text-white hover:text-gray-900 hover:text-white focus:outline-none focus:ring-white"
|
||||
onClick={toggleNavVisible}
|
||||
>
|
||||
<span className="sr-only">Open sidebar</span>
|
||||
|
|
@ -148,8 +156,10 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div className={"nav-mask" + (navVisible?' active':'')} onClick={toggleNavVisible}>
|
||||
</div>
|
||||
<div
|
||||
className={'nav-mask' + (navVisible ? ' active' : '')}
|
||||
onClick={toggleNavVisible}
|
||||
></div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue