@@ -54,7 +54,9 @@ public LLMService(
5454 CancellationToken cancellationToken = default )
5555 {
5656 if ( chat . Messages . Count == 0 )
57+ {
5758 return null ;
59+ }
5860
5961 var lastMsg = chat . Messages . Last ( ) ;
6062
@@ -89,7 +91,9 @@ public Task<string[]> GetCurrentModels()
8991 public Task CleanSessionCache ( string ? id )
9092 {
9193 if ( string . IsNullOrEmpty ( id ) || ! _sessionCache . TryRemove ( id , out var session ) )
94+ {
9295 return Task . CompletedTask ;
96+ }
9397
9498 session . Executor . Context . Dispose ( ) ;
9599 return Task . CompletedTask ;
@@ -309,7 +313,9 @@ private static async Task ProcessImageMessage(Conversation conversation,
309313 conversation . Prompt ( imageEmbeddings ! ) ;
310314
311315 while ( executor . BatchedTokenCount > 0 )
316+ {
312317 await executor . Infer ( cancellationToken ) ;
318+ }
313319
314320 var prompt = llmModel . Tokenize ( $ "USER: { lastMsg . Content } \n ASSISTANT:", true , false , Encoding . UTF8 ) ;
315321 conversation . Prompt ( prompt ) ;
@@ -363,7 +369,9 @@ private static string FormatToolsForPrompt(ToolsConfiguration toolsConfig)
363369 foreach ( var tool in toolsConfig . Tools )
364370 {
365371 if ( tool . Function == null )
372+ {
366373 continue ;
374+ }
367375
368376 toolsList . AppendLine ( $ "- { tool . Function . Name } : { tool . Function . Description } ") ;
369377 toolsList . AppendLine ( $ " Parameters: { JsonSerializer . Serialize ( tool . Function . Parameters ) } ") ;
@@ -673,7 +681,7 @@ await requestOptions.ToolCallback.Invoke(new ToolInvocation
673681
674682 if ( iterations >= MaxToolIterations )
675683 {
676- var errorMessage = "Maximum tool invocation iterations reached. Ending the conversation ." ;
684+ var errorMessage = "Maximum tool invocation iterations reached. Ending the tool-loop prematurely ." ;
677685 var iterationMessage = new Message
678686 {
679687 Content = errorMessage ,
0 commit comments