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

Kendra queries are failing with langchain update #202

Closed
supreetkt opened this issue Sep 19, 2024 · 4 comments · Fixed by #203
Closed

Kendra queries are failing with langchain update #202

supreetkt opened this issue Sep 19, 2024 · 4 comments · Fixed by #203
Assignees

Comments

@supreetkt
Copy link

supreetkt commented Sep 19, 2024

After a recent upgrade to langchain-aws (from v0.1.12 to v0.2.0), I'm noticing my kendra retrieval fail due to pydantic errors:

Validation errors for RetrieveResult\nResultItems.0.DocumentAttributes.0.Value.DateValue
Field required [type=missing, input_value={'StringValue': 'http://d...NotificationHowTo.html'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
ResultItems.0.DocumentAttributes.0.Value.LongValue\n  Field required [type=missing, input_value={'StringValue': 'http://d...NotificationHowTo.html'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing\nResultItems.0.DocumentAttributes.0.Value.StringListValue\n  Field required [type=missing, input_value={'StringValue': 'http://d...NotificationHowTo.html'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing\nResultItems.1.DocumentAttributes.0.Value.DateValue\n  Field required [type=missing, input_value={'StringValue': 'http://d...NotificationHowTo.html'}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.9/v/missing

Essentially, the retrieved results from Kendra are not fitting the pydantic schema set out for DocumentAttributeValue:

class DocumentAttributeValue(BaseModel, extra="allow"):  # type: ignore[call-arg]
    """Value of a document attribute."""

    DateValue: Optional[str]
    """The date expressed as an ISO 8601 string."""
    LongValue: Optional[int]
    """The long value."""
    StringListValue: Optional[List[str]]
    """The string list value."""
    StringValue: Optional[str]
    """The string value."""

Setting DateValue, LongValue, StringListValue and StringValue "optional" values are no longer working optionally. A default value of None needs to be set up on these above like below which would fix these issues:

class DocumentAttributeValue(BaseModel, extra="allow"):  # type: ignore[call-arg]
    """Value of a document attribute."""

    DateValue: Optional[str] = None
    """The date expressed as an ISO 8601 string."""
    LongValue: Optional[int] = None
    """The long value."""
    StringListValue: Optional[List[str]] = None
    """The string list value."""
    StringValue: Optional[str] = None
    """The string value."""

I'm assuming this has to do with a pydantic upgrade.

@langcarl langcarl bot added the investigate label Sep 19, 2024
@ccurme ccurme self-assigned this Sep 19, 2024
@supreetkt supreetkt changed the title Kendra queries are failing Kendra queries are failing with langchain update Sep 19, 2024
@ccurme
Copy link
Contributor

ccurme commented Sep 19, 2024

Thanks @supreetkt for reporting this. Would you mind taking a look at #203 and confirming this will fix your workflow?

@vaibhavqrcg
Copy link

I'm still getting this issue on latest release today 0.2.7, does this still needs fixing?

@Spencer10798
Copy link

Still an error on latest

@supreetkt
Copy link
Author

This was fixed when it was last reported. Maybe open another issue with the new version and error details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants