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

Add cohere v2/rerank support #8421

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

vibhavbhat
Copy link
Contributor

@vibhavbhat vibhavbhat commented Feb 9, 2025

Title

Add cohere v2/rerank support

Relevant issues

Fixes #8194

Type

πŸ†• New Feature
πŸ› Bug Fix
πŸ“– Documentation
βœ… Test

Changes

Cohere recently introduced its new v2 client, which it recommends over the deprecated v1 client. The main change with the new client is that it has a new num_tokens_per_doc param that replaces the num_chunks_per_doc param. This PR adds support for calling the /v2/rerank cohere endpoint, as well as makes it the default for any /rerank calls. Users can still call v1/rerank to use the v1 client, and the v1 client will still be used if the user passes in the old num_chunks_per_doc param (in order to not break any existing integrations).

This PR should fix the bug where langchain expects the v2 client when calling the cohere rerank endpoint (#8194)

[REQUIRED] Testing - Attach a screenshot of any new tests passing locally

If UI changes, send a screenshot/GIF of working UI fixes

E2E test passes:
image

Unit test passes (all 9 cases):
image

Copy link

vercel bot commented Feb 9, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
litellm βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Feb 11, 2025 8:39am

@krrishdholakia
Copy link
Contributor

πŸ‘‘

@krrishdholakia
Copy link
Contributor

Note: the relevant doc to update is this one - https://docs.litellm.ai/docs/rerank

@vibhavbhat
Copy link
Contributor Author

vibhavbhat commented Feb 11, 2025

PR is ready for review. Added an e2e test w/ mocking, let me know if I should also add one with the real call to Cohere
@krrishdholakia @ishaan-jaff

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

Successfully merging this pull request may close these issues.

[Feature]: Need support for /v2/rerank
2 participants