Skip to content

Commit ed5a1c1

Browse files
authored
BugFix Issue #3731 json schema input schema (#3845)
1 parent eccb0b9 commit ed5a1c1

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

extensions/src/AWSSDK.Extensions.Bedrock.MEAI/AWSSDK.Extensions.Bedrock.MEAI.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>AWSSDK.Extensions.Bedrock.MEAI</id>
55
<title>AWSSDK - Bedrock integration with Microsoft.Extensions.AI.</title>
6-
<version>4.0.1.0</version>
6+
<version>4.0.1.1</version>
77
<authors>Amazon Web Services</authors>
88
<description>Implementations of Microsoft.Extensions.AI's abstractions for Bedrock.</description>
99
<language>en-US</language>

extensions/src/AWSSDK.Extensions.Bedrock.MEAI/BedrockChatClient.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ private static string GetMimeType(VideoFormat? format) =>
592592
/// <summary>Converts a <see cref="Dictionary{String, Object}"/> to a <see cref="Document"/>.</summary>
593593
private static Document DictionaryToDocument(IDictionary<string, object?>? arguments)
594594
{
595-
Document inputs = default;
595+
Document inputs = new Document(new Dictionary<string, Document>());
596596
if (arguments is not null)
597597
{
598598
foreach (KeyValuePair<string, object?> argument in arguments)
@@ -704,6 +704,21 @@ private static Document ToDocument(JsonElement json)
704704
}
705705
}
706706

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+
707722
return new Tool()
708723
{
709724
ToolSpec = new ToolSpecification()
@@ -712,12 +727,7 @@ private static Document ToDocument(JsonElement json)
712727
Description = !string.IsNullOrEmpty(f.Description) ? f.Description : f.Name,
713728
InputSchema = new()
714729
{
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)
721731
},
722732
},
723733
};

0 commit comments

Comments
 (0)