@@ -67,6 +67,7 @@ public override ExecutorBaseState GetStateData()
6767 } ;
6868 return state ;
6969 }
70+
7071 /// <inheritdoc />
7172 public override Task LoadState ( ExecutorBaseState data )
7273 {
@@ -88,23 +89,23 @@ public override Task LoadState(ExecutorBaseState data)
8889
8990 return Task . CompletedTask ;
9091 }
92+
9193 /// <inheritdoc />
9294 public override async Task SaveState ( string filename )
9395 {
9496 var state = ( InteractiveExecutorState ) GetStateData ( ) ;
95- using ( var fs = new FileStream ( filename , FileMode . Create , FileAccess . Write ) )
97+ using ( var fs = new FileStream ( filename , FileMode . Create , FileAccess . Write ) )
9698 {
9799 await JsonSerializer . SerializeAsync ( fs , state ) ;
98100 }
99101 }
102+
100103 /// <inheritdoc />
101104 public override async Task LoadState ( string filename )
102105 {
103- using ( var fs = new FileStream ( filename , FileMode . Open , FileAccess . Read ) )
104- {
105- var state = await JsonSerializer . DeserializeAsync < InteractiveExecutorState > ( fs ) ;
106- await LoadState ( state ! ) ;
107- }
106+ using var fs = new FileStream ( filename , FileMode . Open , FileAccess . Read ) ;
107+ var state = await JsonSerializer . DeserializeAsync < InteractiveExecutorState > ( fs ) ;
108+ await LoadState ( state ! ) ;
108109 }
109110
110111 /// <summary>
@@ -122,7 +123,11 @@ protected override Task PreprocessInputs(string? text, InferStateArgs args)
122123 if ( _is_prompt_run )
123124 {
124125 // When running the first input (prompt) in interactive mode, we should specially process it.
125- if ( text == null ) throw new ArgumentException ( "Prompt cannot be null to trigger continuation if a prompt has not been provided previously." ) ;
126+ if ( text == null )
127+ {
128+ throw new ArgumentException ( "Prompt cannot be null to trigger continuation if a prompt has not been provided previously." ) ;
129+ }
130+
126131 if ( ! IsMultiModal )
127132 {
128133 _embed_inps = Context . Tokenize ( text , true , true ) . ToList ( ) ;
@@ -203,15 +208,19 @@ private Task PreprocessLlava(string text, InferStateArgs args, bool addBos = tru
203208 /// <param name="inferenceParams"></param>
204209 /// <param name="args"></param>
205210 /// <returns></returns>
206- protected override async Task < ( bool , IReadOnlyList < string > ) > PostProcess ( IInferenceParams inferenceParams , InferStateArgs args )
211+ protected override ( bool , IReadOnlyList < string > ) PostProcess ( IInferenceParams inferenceParams , InferStateArgs args )
207212 {
208213 if ( _embed_inps . Count <= _consumedTokensCount )
209214 {
210215 if ( ! string . IsNullOrEmpty ( args . LastOutput ) && AntipromptProcessor . Add ( args . LastOutput ) )
216+ {
211217 args . WaitForInput = true ;
218+ }
212219
213220 if ( _pastTokensCount > 0 && args . WaitForInput )
221+ {
214222 return ( true , Array . Empty < string > ( ) ) ;
223+ }
215224 }
216225
217226 if ( _embeds . Count > 0 && _embeds . Last ( ) . IsEndOfGeneration ( Context . Vocab ) )
0 commit comments