feat: add COHERE_API_URL support for custom Cohere rerank endpoints#47
Open
busla wants to merge 2 commits intodanny-avila:mainfrom
Open
feat: add COHERE_API_URL support for custom Cohere rerank endpoints#47busla wants to merge 2 commits intodanny-avila:mainfrom
busla wants to merge 2 commits intodanny-avila:mainfrom
Conversation
Allow configuring a custom Cohere API URL via the COHERE_API_URL environment variable, falling back to the default api.cohere.com/v2/rerank endpoint when not set. This mirrors the existing JINA_API_URL pattern for JinaReranker and enables users to use Cohere-compatible reranking endpoints like LiteLLM proxy or other self-hosted solutions. Changes: - Add apiUrl property to CohereReranker class - Add apiUrl parameter to CohereReranker constructor with env var fallback - Update rerank method to use dynamic apiUrl instead of hardcoded URL - Add cohereApiUrl parameter to createReranker factory function Co-Authored-By: Claude <noreply@anthropic.com>
- Test default API URL (https://api.cohere.com/v2/rerank) - Test custom API URL via constructor parameter - Test COHERE_API_URL environment variable support - Test explicit apiUrl parameter takes precedence over env var - Test createReranker factory with cohereApiUrl option - Test debug logging includes the API URL being used Co-Authored-By: Claude <noreply@anthropic.com>
14 tasks
This file contains hidden or 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
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.
Summary
COHERE_API_URLenvironment variableapi.cohere.com/v2/rerankendpoint when not setJINA_API_URLpattern for JinaRerankerMotivation
Users want to use Cohere-compatible reranking endpoints like LiteLLM proxy or other self-hosted solutions. Currently, the Cohere reranker URL is hardcoded, preventing this use case.
Related: danny-avila/LibreChat#5944
Changes
apiUrlproperty toCohereRerankerclassapiUrlparameter toCohereRerankerconstructor with env var fallbackrerankmethod to use dynamicapiUrlinstead of hardcoded URLcohereApiUrlparameter tocreateRerankerfactory functionTest plan
COHERE_API_URLto a custom endpoint and verify requests go thereCOHERE_API_URLunset and verify fallback to default URL worksDependency: danny-avila/LibreChat#9544