/
githubmirror
/
Open-Assistant
Обзор
Документация
Войти
/
githubmirror
/
Open-Assistant
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/src/utils/chat.ts
32 строки
993 B
Dragan Jovanović
Custom instructions feature (#3597)
31 июл 2023, 00:17
Не верифицирован
31 июл 2023, 00:17
7a68b59
Код
Авторство
О чём код?
import { PluginEntry } from "src/types/Chat"; import { SamplingParameters, CustomInstructionsType } 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 custom_instructions: CustomInstructionsType; }; 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; };