@@ -174,18 +174,18 @@ protected async Task LoadHistory()
174174
175175 string GetSavePath ( string filename )
176176 {
177- return Path . Combine ( Application . persistentDataPath , filename ) ;
177+ return Path . Combine ( Application . persistentDataPath , filename ) . Replace ( ' \\ ' , '/' ) ;
178178 }
179179
180180 string GetJsonSavePath ( string filename )
181181 {
182182 return GetSavePath ( filename + ".json" ) ;
183183 }
184184
185- string GetCacheName ( string filename )
185+ string GetCacheSavePath ( string filename )
186186 {
187187 // this is saved already in the Application.persistentDataPath folder
188- return filename + ".cache" ;
188+ return GetSavePath ( filename + ".cache" ) ;
189189 }
190190
191191 private void InitPrompt ( bool clearChat = true )
@@ -522,11 +522,11 @@ public async Task<string> Detokenize(List<int> tokens, Callback<string> callback
522522 return await PostRequest < TokenizeRequest , string > ( json , "detokenize" , DetokenizeContent , callback ) ;
523523 }
524524
525- private async Task < string > Slot ( string filename , string action )
525+ private async Task < string > Slot ( string filepath , string action )
526526 {
527527 SlotRequest slotRequest = new SlotRequest ( ) ;
528528 slotRequest . id_slot = id_slot ;
529- slotRequest . filename = filename ;
529+ slotRequest . filepath = filepath ;
530530 slotRequest . action = action ;
531531 string json = JsonUtility . ToJson ( slotRequest ) ;
532532 return await PostRequest < SlotResult , string > ( json , "slots" , SlotContent ) ;
@@ -540,12 +540,14 @@ private async Task<string> Slot(string filename, string action)
540540 public async Task < string > Save ( string filename )
541541 {
542542 string filepath = GetJsonSavePath ( filename ) ;
543+ string dirname = Path . GetDirectoryName ( filepath ) ;
544+ if ( ! Directory . Exists ( dirname ) ) Directory . CreateDirectory ( dirname ) ;
543545 string json = JsonUtility . ToJson ( new ChatListWrapper { chat = chat } ) ;
544546 File . WriteAllText ( filepath , json ) ;
545547
546- string cachename = GetCacheName ( filename ) ;
548+ string cachepath = GetCacheSavePath ( filename ) ;
547549 if ( remote || ! saveCache ) return null ;
548- string result = await Slot ( cachename , "save" ) ;
550+ string result = await Slot ( cachepath , "save" ) ;
549551 return result ;
550552 }
551553
@@ -566,9 +568,9 @@ public async Task<string> Load(string filename)
566568 chat = JsonUtility . FromJson < ChatListWrapper > ( json ) . chat ;
567569 Debug . Log ( $ "Loaded { filepath } ") ;
568570
569- string cachename = GetCacheName ( filename ) ;
570- if ( remote || ! saveCache || ! File . Exists ( GetSavePath ( cachename ) ) ) return null ;
571- string result = await Slot ( cachename , "restore" ) ;
571+ string cachepath = GetCacheSavePath ( filename ) ;
572+ if ( remote || ! saveCache || ! File . Exists ( GetSavePath ( cachepath ) ) ) return null ;
573+ string result = await Slot ( cachepath , "restore" ) ;
572574 return result ;
573575 }
574576
0 commit comments