File tree Expand file tree Collapse file tree 5 files changed +26
-0
lines changed Expand file tree Collapse file tree 5 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ interface ChatCommands {
38
38
next ?: Command ;
39
39
prev ?: Command ;
40
40
clear ?: Command ;
41
+ fork ?: Command ;
41
42
del ?: Command ;
42
43
}
43
44
Original file line number Diff line number Diff line change @@ -980,6 +980,7 @@ function _Chat() {
980
980
chatStore . updateCurrentSession (
981
981
( session ) => ( session . clearContextIndex = session . messages . length ) ,
982
982
) ,
983
+ fork : ( ) => chatStore . forkSession ( ) ,
983
984
del : ( ) => chatStore . deleteSession ( chatStore . currentSessionIndex ) ,
984
985
} ) ;
985
986
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ const cn = {
52
52
next : "下一个聊天" ,
53
53
prev : "上一个聊天" ,
54
54
clear : "清除上下文" ,
55
+ fork : "复制聊天" ,
55
56
del : "删除聊天" ,
56
57
} ,
57
58
InputActions : {
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ const en: LocaleType = {
54
54
next : "Next Chat" ,
55
55
prev : "Previous Chat" ,
56
56
clear : "Clear Context" ,
57
+ fork : "Copy Chat" ,
57
58
del : "Delete Chat" ,
58
59
} ,
59
60
InputActions : {
Original file line number Diff line number Diff line change @@ -170,6 +170,28 @@ export const useChatStore = createPersistStore(
170
170
}
171
171
172
172
const methods = {
173
+ forkSession ( ) {
174
+ // 获取当前会话
175
+ const currentSession = get ( ) . currentSession ( ) ;
176
+ if ( ! currentSession ) return ;
177
+
178
+ const newSession = createEmptySession ( ) ;
179
+
180
+ newSession . topic = currentSession . topic ;
181
+ newSession . messages = [ ...currentSession . messages ] ;
182
+ newSession . mask = {
183
+ ...currentSession . mask ,
184
+ modelConfig : {
185
+ ...currentSession . mask . modelConfig ,
186
+ } ,
187
+ } ;
188
+
189
+ set ( ( state ) => ( {
190
+ currentSessionIndex : 0 ,
191
+ sessions : [ newSession , ...state . sessions ] ,
192
+ } ) ) ;
193
+ } ,
194
+
173
195
clearSessions ( ) {
174
196
set ( ( ) => ( {
175
197
sessions : [ createEmptySession ( ) ] ,
You can’t perform that action at this time.
0 commit comments