mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
fix(python): support Cohere embed-v4.0 in CohereEmbeddingFunction (#4805)
`CohereEmbeddingFunction(name="embed-v4.0")` raised `ValueError: Model embed-v4.0 not supported`. **Cause.** `ndims()` uses a closed list of v2/v3 model names and raises for everything else, so Cohere's current embedding model was rejected. **Fix.** Add `embed-v4.0` to `ndims()`, returning its default output dimension (1536). **Test.** `test_cohere_embed_v4_is_supported` creates the function with `name="embed-v4.0"` and checks `ndims() == 1536`. It fails before the change with the `ValueError` and passes after; the existing Cohere default-model test still passes. This change was prepared with the help of an AI assistant (Claude Code), and the author is responsible for the change. ---------
This commit is contained in:
@@ -50,6 +50,7 @@ class CohereEmbeddingFunction(TextEmbeddingFunction):
|
||||
* embed-multilingual-v3.0
|
||||
* embed-english-light-v3.0
|
||||
* embed-multilingual-light-v3.0
|
||||
* embed-v4.0 (1536-dimensional by default)
|
||||
|
||||
The v2.0 models (embed-english-v2.0, embed-english-light-v2.0 and
|
||||
embed-multilingual-v2.0) were retired by Cohere on April 4, 2026.
|
||||
@@ -198,6 +199,9 @@ class CohereEmbeddingFunction(TextEmbeddingFunction):
|
||||
return 1024
|
||||
elif self.name in ["embed-english-light-v3.0", "embed-multilingual-light-v3.0"]:
|
||||
return 384
|
||||
elif self.name == "embed-v4.0":
|
||||
# Default output dimension of embed-v4.0
|
||||
return 1536
|
||||
elif self.name == "embed-english-v2.0":
|
||||
return 4096
|
||||
elif self.name == "embed-multilingual-v2.0":
|
||||
|
||||
@@ -1283,3 +1283,9 @@ def test_cohere_default_model_is_not_a_retired_v2_model():
|
||||
assert cohere.name == "embed-multilingual-v3.0"
|
||||
assert "v2.0" not in cohere.name
|
||||
assert cohere.ndims() == 1024
|
||||
|
||||
|
||||
def test_cohere_embed_v4_is_supported():
|
||||
cohere = get_registry().get("cohere").create(name="embed-v4.0")
|
||||
|
||||
assert cohere.ndims() == 1536
|
||||
|
||||
Reference in New Issue
Block a user