* add systemMessage * perf: 优化代码和类型 * perf: 补全翻译和为以后做准备 --------- Co-authored-by: ChenZhaoYu <790348264@qq.com>
24 lines
704 B
TypeScript
24 lines
704 B
TypeScript
import { ss } from '@/utils/storage'
|
|
|
|
const LOCAL_NAME = 'settingsStorage'
|
|
|
|
export interface SettingsState {
|
|
systemMessage: string
|
|
}
|
|
|
|
export function defaultSetting(): SettingsState {
|
|
const currentDate = new Date().toISOString().split('T')[0]
|
|
return {
|
|
systemMessage: `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: ${currentDate}`,
|
|
}
|
|
}
|
|
|
|
export function getLocalState(): SettingsState {
|
|
const localSetting: SettingsState | undefined = ss.get(LOCAL_NAME)
|
|
return { ...defaultSetting(), ...localSetting }
|
|
}
|
|
|
|
export function setLocalState(setting: SettingsState): void {
|
|
ss.set(LOCAL_NAME, setting)
|
|
}
|