-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
fix(voyage): add voyage-4 embedding models to model cost map #32987
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import pytest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import litellm | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| VOYAGE_4_MODELS = { | ||||||||||||||||||||||||||||
| "voyage/voyage-4-large": 1.2e-07, | ||||||||||||||||||||||||||||
| "voyage/voyage-4": 6e-08, | ||||||||||||||||||||||||||||
| "voyage/voyage-4-lite": 2e-08, | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @pytest.mark.parametrize("model,input_cost", VOYAGE_4_MODELS.items()) | ||||||||||||||||||||||||||||
| def test_voyage_4_model_info(model, input_cost): | ||||||||||||||||||||||||||||
| json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json" | ||||||||||||||||||||||||||||
| with open(json_path) as f: | ||||||||||||||||||||||||||||
| model_cost = json.load(f) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| info = model_cost.get(model) | ||||||||||||||||||||||||||||
| assert info is not None, f"{model} not found in model_prices_and_context_window.json" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| assert info["litellm_provider"] == "voyage" | ||||||||||||||||||||||||||||
| assert info["mode"] == "embedding" | ||||||||||||||||||||||||||||
| assert info["input_cost_per_token"] == input_cost | ||||||||||||||||||||||||||||
| assert info["output_cost_per_token"] == 0.0 | ||||||||||||||||||||||||||||
| assert info["max_input_tokens"] == 32000 | ||||||||||||||||||||||||||||
| assert info["max_tokens"] == 32000 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @pytest.mark.parametrize("model,input_cost", VOYAGE_4_MODELS.items()) | ||||||||||||||||||||||||||||
| def test_voyage_4_get_model_info_surfaces_mode(model, input_cost): | ||||||||||||||||||||||||||||
| litellm.model_cost = litellm.get_model_cost_map(url="") | ||||||||||||||||||||||||||||
| info = litellm.get_model_info(model=model) | ||||||||||||||||||||||||||||
| assert info["mode"] == "embedding" | ||||||||||||||||||||||||||||
| assert info["input_cost_per_token"] == input_cost | ||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @pytest.mark.parametrize("model", VOYAGE_4_MODELS.keys()) | ||||||||||||||||||||||||||||
| def test_voyage_4_backup_matches_main(model): | ||||||||||||||||||||||||||||
| repo_root = Path(__file__).parents[2] | ||||||||||||||||||||||||||||
| main_path = repo_root / "model_prices_and_context_window.json" | ||||||||||||||||||||||||||||
| backup_path = repo_root / "litellm" / "model_prices_and_context_window_backup.json" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| with open(main_path) as f: | ||||||||||||||||||||||||||||
| main_cost = json.load(f) | ||||||||||||||||||||||||||||
| with open(backup_path) as f: | ||||||||||||||||||||||||||||
| backup_cost = json.load(f) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| assert backup_cost.get(model) == main_cost.get(model), ( | ||||||||||||||||||||||||||||
| f"{model} differs between main and backup model cost maps" | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
litellm.model_costis a module-level singleton; assigning to it here and never restoring it means any test that runs after this one in the same pytest worker will see the modified value. If, for example, the module-level cost map was already populated from the remote URL before this test ran, subsequent tests that rely on the original value could produce wrong results or false-positive passes. Use amonkeypatchfixture (or@pytest.fixture(autouse=True)) to scope the override to this test only.