@@ -55,7 +55,9 @@ public LLMService(
5555 CancellationToken cancellationToken = default )
5656 {
5757 if ( chat . Messages . Count == 0 )
58+ {
5859 return null ;
60+ }
5961
6062 var lastMsg = chat . Messages . Last ( ) ;
6163
@@ -90,7 +92,9 @@ public Task<string[]> GetCurrentModels()
9092 public Task CleanSessionCache ( string ? id )
9193 {
9294 if ( string . IsNullOrEmpty ( id ) || ! _sessionCache . TryRemove ( id , out var session ) )
95+ {
9396 return Task . CompletedTask ;
97+ }
9498
9599 session . Executor . Context . Dispose ( ) ;
96100 return Task . CompletedTask ;
@@ -310,7 +314,9 @@ private static async Task ProcessImageMessage(Conversation conversation,
310314 conversation . Prompt ( imageEmbeddings ! ) ;
311315
312316 while ( executor . BatchedTokenCount > 0 )
317+ {
313318 await executor . Infer ( cancellationToken ) ;
319+ }
314320
315321 var prompt = llmModel . Tokenize ( $ "USER: { lastMsg . Content } \n ASSISTANT:", true , false , Encoding . UTF8 ) ;
316322 conversation . Prompt ( prompt ) ;
@@ -364,7 +370,9 @@ private static string FormatToolsForPrompt(ToolsConfiguration toolsConfig)
364370 foreach ( var tool in toolsConfig . Tools )
365371 {
366372 if ( tool . Function == null )
373+ {
367374 continue ;
375+ }
368376
369377 toolsList . AppendLine ( $ "- { tool . Function . Name } : { tool . Function . Description } ") ;
370378 toolsList . AppendLine ( $ " Parameters: { JsonSerializer . Serialize ( tool . Function . Parameters ) } ") ;
@@ -671,7 +679,7 @@ await requestOptions.ToolCallback.Invoke(new ToolInvocation
671679
672680 if ( iterations >= MaxToolIterations )
673681 {
674- var errorMessage = "Maximum tool invocation iterations reached. Ending the conversation ." ;
682+ var errorMessage = "Maximum tool invocation iterations reached. Ending the tool-loop prematurely ." ;
675683 var iterationMessage = new Message
676684 {
677685 Content = errorMessage ,
0 commit comments