- Newest
- Most votes
- Most comments
The error you're encountering suggests that the STARTS_WITH filter is not accepting an array as its value. According to the boto3 documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agent-runtime/client/retrieve.html, the value for startsWith should be a single string, not an array of strings.
Here's a more precise way to handle this scenario: Use Multiple Filters: Instead of sending an array of URLs, you can apply multiple startsWith filters for each URL. Logical Combinations: If the API allows combining multiple filters with logical OR conditions, use that. Given your current setup, you need to apply each startsWith filter separately. Here's an example of how you might structure it if logical combinations are allowed:
Example with Multiple startsWith Filters
vectorSearchConfiguration = {
'filter': {
'or': [
{'startsWith': {'key': 'x-amz-bedrock-kb-source-uri', 'value': 's3://bedrock-sp/folder/subfolder1/'}},
{'startsWith': {'key': 'x-amz-bedrock-kb-source-uri', 'value': 's3://bedrock-sp/folder/subfolder2/'}}
]
}
}
If you need to apply filters separately, you would have to create separate requests or iterate through your filters.
bro @A_J,
I did tests and I was able to send 5 different urls, the problem is that there is only a limit (5), I tried to make a combination but when I ask a question about a subfolder it does not return information, I leave the example and continue doing tests to achieve a result that returns the information of each url that I send, thanks:
{
"orAll":[
{
"orAll":[
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub1/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub2/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub3/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub4/"
}
}
]
},
{
"orAll":[
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub5/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub6/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub7/"
}
},
{
"startsWith":{
"key":"x-amz-bedrock-kb-source-uri",
"value":"s3://bedrock-sp/folderB/sub8/"
}
}
]
}
]
}
Relevant content
- asked 7 months ago
- asked a year ago
- AWS OFFICIALUpdated 7 months ago
I leave a response with my tests, thank you