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

fix(cohere,langchain): handle exceptions in compressDocuments and formatDocuments methods due to empty documents #7372

Merged
merged 3 commits into from
Dec 24, 2024

Conversation

ahm750
Copy link
Contributor

@ahm750 ahm750 commented Dec 16, 2024

Fixes #7370

  1. Prevent the invalid request: list of documents must not be empty error caused by compressDocuments method due to documents being empty. Added a condition to check if documents is empty. If yes, return an empty array.

  2. Prevent exception thrown from formattedDocs methods when documents is empty. Added a condition to check if documents is empty. If yes, return an empty string.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
…nts if the documents parameter is null or empty
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 16, 2024
Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Dec 16, 2024 11:22pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Dec 16, 2024 11:22pm

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 16, 2024
@ahm750 ahm750 changed the title Fixes #7370: handle empty documents in compressDocuments and formatDocuments methods Fixes #7370: handle exceptions in compressDocuments and formatDocuments methods due to empty documents Dec 16, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
@ahm750
Copy link
Contributor Author

ahm750 commented Dec 16, 2024

@jacoblee93 applied the changes you requested.

@ahm750
Copy link
Contributor Author

ahm750 commented Dec 20, 2024

Can you ensure this fix is included in the next release? We're unable to use the Cohere reranker due to this bug.

@jacoblee93 jacoblee93 changed the title Fixes #7370: handle exceptions in compressDocuments and formatDocuments methods due to empty documents fix(cohere,langchain): handle exceptions in compressDocuments and formatDocuments methods due to empty documents Dec 24, 2024
@jacoblee93
Copy link
Collaborator

Hey apologies for the delay! Will aim to get it out tonight

@jacoblee93 jacoblee93 added the lgtm PRs that are ready to be merged as-is label Dec 24, 2024
@jacoblee93 jacoblee93 merged commit 9039484 into langchain-ai:main Dec 24, 2024
34 checks passed
@ahm750
Copy link
Contributor Author

ahm750 commented Dec 24, 2024

Hey apologies for the delay! Will aim to get it out tonight

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature lgtm PRs that are ready to be merged as-is size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cohere rerank exception: invalid request: list of documents must not be empty
2 participants