commit
9ddd5a0566
|
@ -38,6 +38,7 @@ interface ChatCommands {
|
||||||
next?: Command;
|
next?: Command;
|
||||||
prev?: Command;
|
prev?: Command;
|
||||||
clear?: Command;
|
clear?: Command;
|
||||||
|
fork?: Command;
|
||||||
del?: Command;
|
del?: Command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,7 @@ function _Chat() {
|
||||||
chatStore.updateCurrentSession(
|
chatStore.updateCurrentSession(
|
||||||
(session) => (session.clearContextIndex = session.messages.length),
|
(session) => (session.clearContextIndex = session.messages.length),
|
||||||
),
|
),
|
||||||
|
fork: () => chatStore.forkSession(),
|
||||||
del: () => chatStore.deleteSession(chatStore.currentSessionIndex),
|
del: () => chatStore.deleteSession(chatStore.currentSessionIndex),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ const cn = {
|
||||||
next: "下一个聊天",
|
next: "下一个聊天",
|
||||||
prev: "上一个聊天",
|
prev: "上一个聊天",
|
||||||
clear: "清除上下文",
|
clear: "清除上下文",
|
||||||
|
fork: "复制聊天",
|
||||||
del: "删除聊天",
|
del: "删除聊天",
|
||||||
},
|
},
|
||||||
InputActions: {
|
InputActions: {
|
||||||
|
|
|
@ -54,6 +54,7 @@ const en: LocaleType = {
|
||||||
next: "Next Chat",
|
next: "Next Chat",
|
||||||
prev: "Previous Chat",
|
prev: "Previous Chat",
|
||||||
clear: "Clear Context",
|
clear: "Clear Context",
|
||||||
|
fork: "Copy Chat",
|
||||||
del: "Delete Chat",
|
del: "Delete Chat",
|
||||||
},
|
},
|
||||||
InputActions: {
|
InputActions: {
|
||||||
|
|
|
@ -170,6 +170,28 @@ export const useChatStore = createPersistStore(
|
||||||
}
|
}
|
||||||
|
|
||||||
const methods = {
|
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() {
|
clearSessions() {
|
||||||
set(() => ({
|
set(() => ({
|
||||||
sessions: [createEmptySession()],
|
sessions: [createEmptySession()],
|
||||||
|
|
Loading…
Reference in New Issue