Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bedrock Knowledge Base Search Filter "in" broken #169

Closed
manuwaik opened this issue Aug 27, 2024 · 5 comments
Closed

Bedrock Knowledge Base Search Filter "in" broken #169

manuwaik opened this issue Aug 27, 2024 · 5 comments
Assignees

Comments

@manuwaik
Copy link

https://github.com/langchain-ai/langchain-aws/blame/d89fcf80c61174c21c88ef8d1cfbf3a55c7d84c5/libs/aws/langchain_aws/retrievers/bedrock.py#L24

I get error:

Parameter validation failed:
Unknown parameter in retrievalConfiguration.vectorSearchConfiguration.filter: "in_", must be one of: andAll, equals, greaterThan, greaterThanOrEquals, in, lessThan, lessThanOrEquals, listContains, notEquals, notIn, orAll, startsWith, stringContains
@langcarl langcarl bot added the investigate label Aug 27, 2024
@isahers1
Copy link

Could you show a full code snippet that is causing the error so I can help debug?

@manuwaik
Copy link
Author

manuwaik commented Aug 27, 2024

# Retrieve chunks from relevant documents
retriever = AmazonKnowledgeBasesRetriever(
    knowledge_base_id="XXXXXXXX",
    retrieval_config={"vectorSearchConfiguration": 
                        {
                            "numberOfResults": 5,
                            "filter": {
                                "in": {
                                    "key": "tag",
                                    "value": ["document1", "document2"]
                                    }
                                }
                        }
                     },
)

docs = retriever.invoke("How many stars are in the universe?")

The metadata with key tag exists on the KB.
I have also tried using in_.

@ccurme ccurme assigned isahers1 and unassigned efriis Aug 30, 2024
@karoaper
Copy link

The problem is here: https://github.com/langchain-ai/langchain-aws/blob/main/libs/aws/langchain_aws/retrievers/bedrock.py#L165. The call to model_dump should include "by_alias=True".

@renjiexu-amzn
Copy link
Contributor

renjiexu-amzn commented Oct 10, 2024

Oh, karoaper beated me on commenting the root cause. Would @isahers1 help merge my change in #233 and release a new minor version with the fix? Do you have an ETA on the release so that I could coordinate the work blocked by this one?

3coins pushed a commit that referenced this issue Oct 15, 2024
#233)

Fixed the issue mentioned in
#169
Added unit test that would expose the bug in source code
Tested with my service code and it works with the change
renjiexu-amzn added a commit to renjiexu-amzn/langchain-aws that referenced this issue Oct 16, 2024
3coins pushed a commit that referenced this issue Oct 16, 2024
@3coins
Copy link
Collaborator

3coins commented Oct 23, 2024

Fixed in v0.2.3.

@3coins 3coins closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants