Open shamspias opened 1 month ago
Facing this very same issue. Wondering when this commit could be merged. Big credits to @shamspias for providing the fix.
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: https://github.com/langchain-ai/langchain/issues/28029
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
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
124