@@ -193,30 +193,6 @@ options.OpenWorld is not null ||
193193 return newOptions ;
194194 }
195195
196- private static CallToolResponse ConvertAiContentEnumerableToCallToolResponse ( IEnumerable < AIContent > contentItems )
197- {
198- List < Content > contentList = [ ] ;
199- bool allErrorContent = true ;
200- bool hasAny = false ;
201-
202- foreach ( var item in contentItems )
203- {
204- contentList . Add ( item . ToContent ( ) ) ;
205- hasAny = true ;
206-
207- if ( allErrorContent && item is not ErrorContent )
208- {
209- allErrorContent = false ;
210- }
211- }
212-
213- return new ( )
214- {
215- Content = contentList ,
216- IsError = allErrorContent && hasAny
217- } ;
218- }
219-
220196 /// <summary>Gets the <see cref="AIFunction"/> wrapped by this tool.</summary>
221197 internal AIFunction AIFunction { get ; }
222198
@@ -301,7 +277,7 @@ public override async ValueTask<CallToolResponse> InvokeAsync(
301277 Content = [ .. texts . Select ( x => new Content ( ) { Type = "text" , Text = x ?? string . Empty } ) ]
302278 } ,
303279
304- IEnumerable < AIContent > contentItems => ConvertAiContentEnumerableToCallToolResponse ( contentItems ) ,
280+ IEnumerable < AIContent > contentItems => ConvertAIContentEnumerableToCallToolResponse ( contentItems ) ,
305281
306282 IEnumerable < Content > contents => new ( )
307283 {
@@ -321,4 +297,27 @@ public override async ValueTask<CallToolResponse> InvokeAsync(
321297 } ;
322298 }
323299
300+ private static CallToolResponse ConvertAIContentEnumerableToCallToolResponse ( IEnumerable < AIContent > contentItems )
301+ {
302+ List < Content > contentList = [ ] ;
303+ bool allErrorContent = true ;
304+ bool hasAny = false ;
305+
306+ foreach ( var item in contentItems )
307+ {
308+ contentList . Add ( item . ToContent ( ) ) ;
309+ hasAny = true ;
310+
311+ if ( allErrorContent && item is not ErrorContent )
312+ {
313+ allErrorContent = false ;
314+ }
315+ }
316+
317+ return new ( )
318+ {
319+ Content = contentList ,
320+ IsError = allErrorContent && hasAny
321+ } ;
322+ }
324323}
0 commit comments