forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.ts
31 lines (25 loc) · 922 Bytes
/
chat.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { PluginEntry } from "src/types/Chat";
import { SamplingParameters } from "src/types/Chat";
const CHAT_CONFIG_KEY = "CHAT_CONFIG_V2";
export type CustomPreset = { name: string; config: SamplingParameters };
export type CachedChatConfig = {
model_config_name: string;
selectedPresetName: string;
custom_preset_config: SamplingParameters;
custom_presets: CustomPreset[];
selectedPlugins: PluginEntry[];
plugins: PluginEntry[]; // all plugins user added
};
export const setConfigCache = (config: CachedChatConfig) => {
if (typeof localStorage !== "undefined") {
localStorage.setItem(CHAT_CONFIG_KEY, JSON.stringify(config));
}
};
export const getConfigCache = (): CachedChatConfig | null => {
if (typeof localStorage !== "undefined") {
const config = localStorage.getItem(CHAT_CONFIG_KEY);
const parsed = config ? JSON.parse(config) : null;
return parsed;
}
return null;
};