quivr/frontend/lib/api/chat/chat.local.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

27 lines
662 B
TypeScript

import { ChatConfig } from "@/lib/context/ChatProvider/types";
const chatConfigLocalStorageKey = "chat-config";
type PartialChatConfig = Partial<ChatConfig>;
export const saveChatsConfigInLocalStorage = (
chatConfig: PartialChatConfig
): void => {
localStorage.setItem(chatConfigLocalStorageKey, JSON.stringify(chatConfig));
};
export const getChatsConfigFromLocalStorage = ():
| PartialChatConfig
| undefined => {
try {
const config = localStorage.getItem(chatConfigLocalStorageKey);
if (config === null) {
return undefined;
}
return JSON.parse(config) as PartialChatConfig;
} catch (error) {
return undefined;
}
};