新增用户意图确认功能
This commit is contained in:
1 parent
cf2e4bdd9c
commit
b8926f00d7
574 files changed
+97664
-97208
No files matched your search
@@ -1,59 +1,59 @@
|
||||
import { useCallback, useMemo, useSyncExternalStore } from "react";
|
||||
|
||||
import {
|
||||
DEFAULT_LOCAL_SETTINGS,
|
||||
applyThreadModelOverride,
|
||||
type LocalSettings,
|
||||
} from "./local";
|
||||
import {
|
||||
getBaseSettingsSnapshot,
|
||||
getThreadModelSnapshot,
|
||||
subscribe,
|
||||
updateLocalSettings,
|
||||
updateThreadSettings,
|
||||
type LocalSettingsSetter,
|
||||
} from "./store";
|
||||
|
||||
export function useLocalSettings(): [LocalSettings, LocalSettingsSetter] {
|
||||
const settings = useSyncExternalStore(
|
||||
subscribe,
|
||||
getBaseSettingsSnapshot,
|
||||
() => DEFAULT_LOCAL_SETTINGS,
|
||||
);
|
||||
|
||||
const setSettings = useCallback<LocalSettingsSetter>((key, value) => {
|
||||
updateLocalSettings(key, value);
|
||||
}, []);
|
||||
|
||||
return [settings, setSettings];
|
||||
}
|
||||
|
||||
export function useThreadSettings(
|
||||
threadId: string,
|
||||
): [LocalSettings, LocalSettingsSetter] {
|
||||
const baseSettings = useSyncExternalStore(
|
||||
subscribe,
|
||||
getBaseSettingsSnapshot,
|
||||
() => DEFAULT_LOCAL_SETTINGS,
|
||||
);
|
||||
|
||||
const threadModelName = useSyncExternalStore(
|
||||
subscribe,
|
||||
() => getThreadModelSnapshot(threadId),
|
||||
() => undefined,
|
||||
);
|
||||
|
||||
const settings = useMemo(
|
||||
() => applyThreadModelOverride(baseSettings, threadModelName),
|
||||
[baseSettings, threadModelName],
|
||||
);
|
||||
|
||||
const setSettings = useCallback<LocalSettingsSetter>(
|
||||
(key, value) => {
|
||||
updateThreadSettings(threadId, key, value);
|
||||
},
|
||||
[threadId],
|
||||
);
|
||||
|
||||
return [settings, setSettings];
|
||||
}
|
||||
import { useCallback, useMemo, useSyncExternalStore } from "react";
|
||||
|
||||
import {
|
||||
DEFAULT_LOCAL_SETTINGS,
|
||||
applyThreadModelOverride,
|
||||
type LocalSettings,
|
||||
} from "./local";
|
||||
import {
|
||||
getBaseSettingsSnapshot,
|
||||
getThreadModelSnapshot,
|
||||
subscribe,
|
||||
updateLocalSettings,
|
||||
updateThreadSettings,
|
||||
type LocalSettingsSetter,
|
||||
} from "./store";
|
||||
|
||||
export function useLocalSettings(): [LocalSettings, LocalSettingsSetter] {
|
||||
const settings = useSyncExternalStore(
|
||||
subscribe,
|
||||
getBaseSettingsSnapshot,
|
||||
() => DEFAULT_LOCAL_SETTINGS,
|
||||
);
|
||||
|
||||
const setSettings = useCallback<LocalSettingsSetter>((key, value) => {
|
||||
updateLocalSettings(key, value);
|
||||
}, []);
|
||||
|
||||
return [settings, setSettings];
|
||||
}
|
||||
|
||||
export function useThreadSettings(
|
||||
threadId: string,
|
||||
): [LocalSettings, LocalSettingsSetter] {
|
||||
const baseSettings = useSyncExternalStore(
|
||||
subscribe,
|
||||
getBaseSettingsSnapshot,
|
||||
() => DEFAULT_LOCAL_SETTINGS,
|
||||
);
|
||||
|
||||
const threadModelName = useSyncExternalStore(
|
||||
subscribe,
|
||||
() => getThreadModelSnapshot(threadId),
|
||||
() => undefined,
|
||||
);
|
||||
|
||||
const settings = useMemo(
|
||||
() => applyThreadModelOverride(baseSettings, threadModelName),
|
||||
[baseSettings, threadModelName],
|
||||
);
|
||||
|
||||
const setSettings = useCallback<LocalSettingsSetter>(
|
||||
(key, value) => {
|
||||
updateThreadSettings(threadId, key, value);
|
||||
},
|
||||
[threadId],
|
||||
);
|
||||
|
||||
return [settings, setSettings];
|
||||
}
|
||||
Reference in new issue
Block a user