-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
vibhavbhat
wants to merge
8
commits into
BerriAI:main
Choose a base branch
from
vibhavbhat:vib/cohere-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
π |
Note: the relevant doc to update is this one - https://docs.litellm.ai/docs/rerank |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thenum_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 callv1/rerank
to use the v1 client, and the v1 client will still be used if the user passes in the oldnum_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](https://private-user-images.githubusercontent.com/10468083/411882544-8bd71a03-ef35-45b7-b65a-3517d5cf1ccc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NzI3OTUsIm5iZiI6MTczOTQ3MjQ5NSwicGF0aCI6Ii8xMDQ2ODA4My80MTE4ODI1NDQtOGJkNzFhMDMtZWYzNS00NWI3LWI2NWEtMzUxN2Q1Y2YxY2NjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDE4NDgxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzYzFkOThlOTU5MDc1NDRiNjc5NDU5NjQ1OWQ2ZjdiOTE1Y2Y1OGIwMWQyYTg4NTAyZDA3M2I5ZTI4MjU2YjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.kpEHbTVaOvgvgETtjsJ5SFfswiX6Zl-NQf6wVnzW7dQ)
Unit test passes (all 9 cases):
![image](https://private-user-images.githubusercontent.com/10468083/411882793-275bd3b5-4b45-4539-be7d-d26268b9cf32.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NzI3OTUsIm5iZiI6MTczOTQ3MjQ5NSwicGF0aCI6Ii8xMDQ2ODA4My80MTE4ODI3OTMtMjc1YmQzYjUtNGI0NS00NTM5LWJlN2QtZDI2MjY4YjljZjMyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDE4NDgxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM5NmNjOTA5MWRmM2FjMzM4M2JiZmU5NTJhMjJkNjMyZjBjYzY4Yzg3ZGEzNWZhOWQ5MGM0ODFjM2I2MWM3MzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0oMMmbj0nu5H_zrDoeYdx_-6xkSTeg_jF4Nmp_5xGII)