-
Notifications
You must be signed in to change notification settings - Fork 870
Description
Describe the feature
The Document class in AWS.Runtime is a simple JSON model class that is used to e.g. pass the JSON schema and response for AWS bedrock tool use.
.NET natively supports JsonNode and JsonDocument/JsonElement for working with JSON. Currently it is difficult to interoperate with these classes:
Document.FromObjectonly supportsJsonElement-- forJsonNodeyou need to do `Document.FromObject(JsonDocument.Parse(node.ToJsonString()).RootElement);- There is no way to convert from a
Documentto aJsonNodeorJsonElement.
Use Case
I have a JsonNode object that defines the JSON schema (via GetJsonSchemaAsNode) that I want to use to specify an AWS Bedrock tool as using (setting the Json property of the ToolSpecification). I also want to use that JSON schema object to deserialize the JSON back into a .NET class. I'm using JsonNode because I need it to work with other parts of the project.
Proposed Solution
I propose for Document.FromObject:
- A
Document.FromObject(JsonDocument doc)overload that evaluates toDocument.FromObject(doc.RootElement); - A
Document.FromObject(JsonNode node)overload that evaluates toDocument.FromObject(JsonDocument.Parse(node.ToJsonString()))or equivalent.
I also propose the following converters to convert to the corresponding .NET types:
JsonDocument Document.AsJsonDocument();JsonElement Document.AsJsonElement();JsonNode Document.AsJsonNode().
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
AWS .NET SDK and/or Package version used
AWS.BedrockRuntime 4.0.1.1
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11