@@ -592,7 +592,7 @@ private static string GetMimeType(VideoFormat? format) =>
592
592
/// <summary>Converts a <see cref="Dictionary{String, Object}"/> to a <see cref="Document"/>.</summary>
593
593
private static Document DictionaryToDocument ( IDictionary < string , object ? > ? arguments )
594
594
{
595
- Document inputs = default ;
595
+ Document inputs = new Document ( new Dictionary < string , Document > ( ) ) ;
596
596
if ( arguments is not null )
597
597
{
598
598
foreach ( KeyValuePair < string , object ? > argument in arguments )
@@ -704,6 +704,21 @@ private static Document ToDocument(JsonElement json)
704
704
}
705
705
}
706
706
707
+ var schemaDictionary = new Dictionary < string , Document > ( )
708
+ {
709
+ [ "type" ] = new Document ( "object" ) ,
710
+ } ;
711
+
712
+ if ( inputs != default )
713
+ {
714
+ schemaDictionary [ "properties" ] = inputs ;
715
+ }
716
+
717
+ if ( required . Count > 0 )
718
+ {
719
+ schemaDictionary [ "required" ] = new Document ( required ) ;
720
+ }
721
+
707
722
return new Tool ( )
708
723
{
709
724
ToolSpec = new ToolSpecification ( )
@@ -712,12 +727,7 @@ private static Document ToDocument(JsonElement json)
712
727
Description = ! string . IsNullOrEmpty ( f . Description ) ? f . Description : f . Name ,
713
728
InputSchema = new ( )
714
729
{
715
- Json = new ( new Dictionary < string , Document > ( )
716
- {
717
- [ "type" ] = new Document ( "object" ) ,
718
- [ "properties" ] = inputs ,
719
- [ "required" ] = new Document ( required ) ,
720
- } )
730
+ Json = new ( schemaDictionary )
721
731
} ,
722
732
} ,
723
733
} ;
0 commit comments