-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix metadata deserialization in async mode for PGVector #125
base: main
Are you sure you want to change the base?
Fix metadata deserialization in async mode for PGVector #125
Conversation
Facing this very same issue. Wondering when this commit could be merged. Regards |
@eyurtsev, please let me know if there is anything else I need to do. If not, please merge it. |
Did you fix the issue? I have related: langchain-ai/langchain#28029 |
yes I did fixed the issue you can use the branch if you like to |
Good work! It has fixed an issue in my langgraph app. Can a maintainer merge this as it's a blocker for us. Thanks! |
Hi @shamspias @samsiuatpurple - I just ran into the same issue and used your PR code. It prevented the error but now it's just returning empty metadata. Assume you aren't having the same? |
It works fine, I run several project with this PR. |
Can someone tell us when this change will be in a release? When is the next release for langchain-postgres? |
same questions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shamspias, are you interested in iterating on this? It still needs some work:
- The code breaks out the gate (
json
is not imported) - Most importantly, there are no tests.
The most useful thing would be a unit test or reproducible example demonstrating how to generate non-dict metadata.
Problem
When using asynchronous methods with
PGVector
(async_mode=True
), themetadata
field retrieved from the database may be of typeFragment
(fromasyncpg
) or other non-dict types. This causes aValidationError
when theDocument
class expectsmetadata
to be a dictionary.Solution
This pull request modifies the
_results_to_docs_and_scores
method to ensure thatmetadata
is correctly converted into a dictionary before creatingDocument
instances. The method now handles different possible types ofmetadata
and attempts to deserialize it into a dict.Changes
_results_to_docs_and_scores
method inPGVector
class to handlemetadata
deserialization for different types (e.g.,dict
,str
,Fragment
).Testing
async_mode=True
and confirmed that themetadata
field is correctly deserialized and no longer causes validation errors.async_mode=False
.Related Issues