Replies: 1 comment
-
PR to address this feature request, langchain-ai/langchain-aws#36 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
AWS Knowledge Bases allows you to create documents with metadata and langchain allows you to filter by them (this is great!)
The problem we encountered is that this metadata is not returned as part of the response.
I've been reviewing the Bedrock documentation and Langchain source code with AWS engineers and supporting this would be very easy.
Motivation
The reason for this request is to be able to obtain all the metadata of the knowledge base, something highly useful for our agents and systems based on langchain.
Proposal (If applicable)
According to the AWS documentation (https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html), in their response they offer the metadata object with the JSON that I am looking for.
{ "nextToken": "string", "retrievalResults": [ { "content": { "text": "string" }, "location": { "s3Location": { "uri": "string" }, "type": "string" }, "metadata": { "string" : JSON value }, "score": number } ] }
In LangChain you can see the code:
Document( page_content=result["content"]["text"], metadata={ "location": result["location"], "score": result["score"] if "score" in result else 0, }, )
You would only have to add the line:
"metadata": result["metadata"],
Document( page_content=result["content"]["text"], metadata={ "location": result["location"], "metadata": result["metadata"], "score": result["score"] if "score" in result else 0, }, )
or
Document( page_content=result["content"]["text"], metadata={ "location": result["location"], "score": result["score"] if "score" in result else 0, **result["metadata"] }, )
Beta Was this translation helpful? Give feedback.
All reactions