Description
Describe the bug
When using the the RetrievalFilter class for a Bedrock KnowledgeBase request it seems the key, value requires that you use the Amazon.Runtime.Documents.Document class within the filter structure. When attempting to use this filtering class the KnowledgeBase service seemed to ignore my filters but after further investigation, it seems the document class cannot be serialized. While trying to troubleshoot the problem I got this exception:
Amazon.Runtime.Documents.InvalidDocumentTypeConversionException: Cannot Convert DocumentType to List because it is String
I tried using this Document class multiple ways but it fails all the same:
retrievalFilter.Equals = new FilterAttribute
{
Key = "TeamId",
Value = new Document(teamsId.ToString())
};
This also fails
retrievalFilter.Equals = new FilterAttribute
{
Key = "TeamId",
Value = teamsId.ToString()
};
When I serialize the object using Serliog's internal serializer, it works but my filter values are empty:
{
"Input": {
"Text": "what is the diagrams about",
"$type": "RetrieveAndGenerateInput"
},
"RetrieveAndGenerateConfiguration": {
"ExternalSourcesConfiguration": null,
"KnowledgeBaseConfiguration": {
"GenerationConfiguration": null,
"KnowledgeBaseId": "28W0R6NFGO",
"ModelArn": "anthropic.claude-3-sonnet-20240229-v1:0",
"OrchestrationConfiguration": null,
"RetrievalConfiguration": {
"VectorSearchConfiguration": {
"Filter": {
"AndAll": [
{
"AndAll": null,
"Equals": {
"Key": "TeamId",
"Value": [
null
],
"$type": "FilterAttribute"
},
"GreaterThan": null,
"GreaterThanOrEquals": null,
"In": null,
"LessThan": null,
"LessThanOrEquals": null,
"ListContains": null,
"NotEquals": null,
"NotIn": null,
"OrAll": null,
"StartsWith": null,
"StringContains": null,
"$type": "RetrievalFilter"
},
{
"AndAll": null,
"Equals": {
"Key": "MeetingId",
"Value": [
null
],
"$type": "FilterAttribute"
},
"GreaterThan": null,
"GreaterThanOrEquals": null,
"In": null,
"LessThan": null,
"LessThanOrEquals": null,
"ListContains": null,
"NotEquals": null,
"NotIn": null,
"OrAll": null,
"StartsWith": null,
"StringContains": null,
"$type": "RetrievalFilter"
}
],
"Equals": null,
"GreaterThan": null,
"GreaterThanOrEquals": null,
"In": null,
"LessThan": null,
"LessThanOrEquals": null,
"ListContains": null,
"NotEquals": null,
"NotIn": null,
"OrAll": null,
"StartsWith": null,
"StringContains": null,
"$type": "RetrievalFilter"
},
"ImplicitFilterConfiguration": null,
"NumberOfResults": null,
"OverrideSearchType": null,
"RerankingConfiguration": null,
"$type": "KnowledgeBaseVectorSearchConfiguration"
},
"$type": "KnowledgeBaseRetrievalConfiguration"
},
"$type": "KnowledgeBaseRetrieveAndGenerateConfiguration"
},
"Type": {
"Value": "KNOWLEDGE_BASE",
"$type": "RetrieveAndGenerateType"
},
"$type": "RetrieveAndGenerateConfiguration"
},
"SessionConfiguration": null,
"SessionId": null,
"$type": "RetrieveAndGenerateRequest"
}
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Document class needs to serializable and should pass the Value defined into the payload.
Current Behavior
Document object is not serializable.
Reproduction Steps
In the details above.
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
4.0.0-Preview5
Targeted .NET Platform
.Net 8.0
Operating System and version
Lambda