quivr/frontend/app/chat/[chatId]/hooks/useLocalStorageChatConfig.ts
Mamadou DICKO 68da22aa1d
feat: update models logic (#1767)
- The frontend no longer sets a default model
- Either a model is chosen by the user, or it will be done by the
backend

Issue: https://github.com/StanGirard/quivr/issues/1747
2023-11-30 22:08:36 +01:00

22 lines
619 B
TypeScript

import { getChatsConfigFromLocalStorage } from "@/lib/api/chat/chat.local";
import { useUserData } from "@/lib/hooks/useUserData";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useLocalStorageChatConfig = () => {
const { userData } = useUserData();
const chatConfig = getChatsConfigFromLocalStorage();
const model = (userData?.models ?? []).includes(chatConfig?.model ?? "")
? chatConfig?.model
: undefined;
return {
chatConfig: {
model: model,
temperature: chatConfig?.temperature,
maxTokens: chatConfig?.maxTokens,
},
};
};