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: Handle empty documents in ContextualCompressionRetriever (Issue #5304) #5306

Merged

Conversation

hanguofeng
Copy link
Contributor

@hanguofeng hanguofeng commented May 26, 2023

Fix: Handle empty documents in ContextualCompressionRetriever (Issue #5304)

Fixes #5304

Prevent cohere.error.CohereAPIError caused by an empty list of documents by adding a condition to check if the input documents list is empty in the compress_documents method. If the list is empty, return an empty list immediately, avoiding the error and unnecessary processing.

@dev2049

Prevent cohere.error.CohereAPIError caused by an empty list of documents by adding a condition to check if the input documents list is empty in the compress_documents method. If the list is empty, return an empty list immediately, avoiding the error and unnecessary processing.
Copy link
Contributor

@dev2049 dev2049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @hanguofeng!

@hwchase17 hwchase17 merged commit 99a1e3f into langchain-ai:master May 28, 2023
12 checks passed
@hanguofeng hanguofeng deleted the dev_fix_cohere_rerank_on_empty branch May 29, 2023 15:13
@danielchalef danielchalef mentioned this pull request Jun 5, 2023
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this pull request Jun 19, 2023
…angchain-ai#5304) (langchain-ai#5306)

# Fix: Handle empty documents in ContextualCompressionRetriever (Issue
langchain-ai#5304)

Fixes langchain-ai#5304 

Prevent cohere.error.CohereAPIError caused by an empty list of documents
by adding a condition to check if the input documents list is empty in
the compress_documents method. If the list is empty, return an empty
list immediately, avoiding the error and unnecessary processing.

@dev2049

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This was referenced Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants