Merge pull request #5432 from ConnectAI-E/Feature-fork

feat fork
This commit is contained in:
Dogtiti
2024-09-18 15:04:27 +08:00
committed by GitHub
5 changed files with 26 additions and 0 deletions

View File

@@ -170,6 +170,28 @@ export const useChatStore = createPersistStore(
}
const methods = {
forkSession() {
// 获取当前会话
const currentSession = get().currentSession();
if (!currentSession) return;
const newSession = createEmptySession();
newSession.topic = currentSession.topic;
newSession.messages = [...currentSession.messages];
newSession.mask = {
...currentSession.mask,
modelConfig: {
...currentSession.mask.modelConfig,
},
};
set((state) => ({
currentSessionIndex: 0,
sessions: [newSession, ...state.sessions],
}));
},
clearSessions() {
set(() => ({
sessions: [createEmptySession()],