Skip to content

Add global Rerank interface with Cohere Rerank model support #276

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

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f52d211
Add Cohere API key configuration
infinityrobot Jul 7, 2025
9cef065
Add base Cohere Provider
infinityrobot Jul 7, 2025
552d894
Add Cohere Capabilities and Models modules
infinityrobot Jul 7, 2025
42b18c3
Add initial Cohere Chat and Embeddings module implementations
infinityrobot Jul 7, 2025
21bfcd4
Add Cohere model support to model and alias rake tasks
infinityrobot Jul 7, 2025
84e17c3
Add Cohere models support to Chat and Vision model specs
infinityrobot Jul 7, 2025
5aa271f
Refactor Embeddings spec to use Constant and custom model dimensions
infinityrobot Jul 7, 2025
eda8151
Add skipped specs for image embeddings to note for future support
infinityrobot Jul 7, 2025
b4fa7a8
Skip Cohere vision model when using remote images in specs
infinityrobot Jul 7, 2025
f6b3511
Add Cohere API key config to documentation
infinityrobot Jul 7, 2025
ddabbab
Remove accidental extend of in progress Cohere::Reranking module
infinityrobot Jul 7, 2025
4ee3228
Update models.json
infinityrobot Jul 7, 2025
c8e659c
Update aliases.json
infinityrobot Jul 7, 2025
0ecbec9
Update VCRs for Cohere model specs
infinityrobot Jul 7, 2025
d41ba45
Fix Parsera nil model ID handling in models.rb
infinityrobot Jul 7, 2025
8c57040
Update available model docs
infinityrobot Jul 7, 2025
b5a6865
Remove empty line in Cohere models module
infinityrobot Jul 7, 2025
7de8301
Remove Rerank reference from Cohere module comment
infinityrobot Jul 7, 2025
3aeaa5f
Add Cohere logos to documentation
infinityrobot Jul 8, 2025
fe9856d
Merge remote-tracking branch 'upstream/main' into add-cohere-provider
infinityrobot Jul 18, 2025
209ae93
Run rake models:update models:docs aliases:generate
infinityrobot Jul 18, 2025
f0083c3
Update Cohere embeddings implementation for updates made in #267
infinityrobot Jul 18, 2025
0cded6f
Rerun Cohere VCRs
infinityrobot Jul 18, 2025
f91143a
Add reranking configuration
infinityrobot Jul 7, 2025
2f73ae6
Add core Rerank and RerankResult classes
infinityrobot Jul 7, 2025
6160e3f
Add initial RubyLLM and Provider Rerank implementation
infinityrobot Jul 7, 2025
03019fc
Add context-specific Rerank implementation
infinityrobot Jul 7, 2025
5bef4ba
Add Cohere reranking support to Cohere Provider
infinityrobot Jul 7, 2025
ee30d9d
Add and update reranking-related model helpers
infinityrobot Jul 7, 2025
4db2065
Add Rerank and RerankResult specs
infinityrobot Jul 7, 2025
ebafce7
Add Rerank documentation
infinityrobot Jul 7, 2025
8ca58f3
Add Rerank spec VCRs
infinityrobot Jul 7, 2025
36669f1
Update Rerank documentation
infinityrobot Jul 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/bedrock-color.svg" alt="Bedrock" class="logo-medium">
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/bedrock-text.svg" alt="Bedrock" class="logo-small">
&nbsp;
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/cohere-color.svg" alt="Cohere" class="logo-medium">
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/cohere-text.svg" alt="Cohere" class="logo-medium">
&nbsp;
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-color.svg" alt="DeepSeek" class="logo-medium">
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-text.svg" alt="DeepSeek" class="logo-small">
&nbsp;
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RubyLLM.configure do |config|
config.anthropic_api_key = ENV.fetch('ANTHROPIC_API_KEY', nil)
config.gemini_api_key = ENV.fetch('GEMINI_API_KEY', nil)
config.deepseek_api_key = ENV.fetch('DEEPSEEK_API_KEY', nil)
config.cohere_api_key = ENV.fetch('COHERE_API_KEY', nil)
config.openrouter_api_key = ENV.fetch('OPENROUTER_API_KEY', nil)
config.ollama_api_base = ENV.fetch('OLLAMA_API_BASE', nil)
config.bedrock_api_key = ENV.fetch('AWS_ACCESS_KEY_ID', nil)
Expand Down
8 changes: 6 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ RubyLLM.configure do |config|
config.anthropic_api_key = ENV.fetch('ANTHROPIC_API_KEY', nil)
config.gemini_api_key = ENV.fetch('GEMINI_API_KEY', nil)
config.deepseek_api_key = ENV.fetch('DEEPSEEK_API_KEY', nil)
config.cohere_api_key = ENV.fetch('COHERE_API_KEY', nil)
config.openrouter_api_key = ENV.fetch('OPENROUTER_API_KEY', nil)
config.ollama_api_base = ENV.fetch('OLLAMA_API_BASE', nil)

Expand All @@ -67,9 +68,10 @@ RubyLLM.configure do |config|

# --- Default Models ---
# Used by RubyLLM.chat, RubyLLM.embed, RubyLLM.paint if no model is specified.
config.default_model = 'gpt-4.1-nano' # Default: 'gpt-4.1-nano'
config.default_model = 'gpt-4.1-nano' # Default: 'gpt-4.1-nano'
config.default_embedding_model = 'text-embedding-3-small' # Default: 'text-embedding-3-small'
config.default_image_model = 'dall-e-3' # Default: 'dall-e-3'
config.default_rerank_model = 'rerank-v3.5' # Default: 'rerank-v3.5'
config.default_image_model = 'dall-e-3' # Default: 'dall-e-3'

# --- Connection Settings ---
config.request_timeout = 120 # Request timeout in seconds (default: 120)
Expand Down Expand Up @@ -104,6 +106,7 @@ Set the corresponding `*_api_key` attribute for each provider you want to enable
* `anthropic_api_key`
* `gemini_api_key`
* `deepseek_api_key`
* `cohere_api_key`
* `openrouter_api_key`
* `bedrock_api_key`, `bedrock_secret_key`, `bedrock_region`, `bedrock_session_token` (See AWS documentation for standard credential methods if not set explicitly).

Expand Down Expand Up @@ -146,6 +149,7 @@ These settings determine which models are used by the top-level helper methods (

* `config.default_model`: Used by `RubyLLM.chat`. Default: `'gpt-4.1-nano'`.
* `config.default_embedding_model`: Used by `RubyLLM.embed`. Default: `'text-embedding-3-small'`.
* `config.default_rerank_model`: Used by `RubyLLM.rerank`. Default: `'rerank-v3.5'`.
* `config.default_image_model`: Used by `RubyLLM.paint`. Default: `'dall-e-3'`.

Choose defaults that match your most common use case and provider availability.
Expand Down
400 changes: 241 additions & 159 deletions docs/guides/available-models.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/guides/rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ RubyLLM.configure do |config|
# Add other provider configurations as needed
config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
config.gemini_api_key = ENV['GEMINI_API_KEY']
config.cohere_api_key = ENV['COHERE_API_KEY']
# ...
end
```
Expand Down
Loading