-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[BE]: register replicate and watsonx as canonical providers #7894
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -973,4 +973,38 @@ private static Stream<Arguments> provideAggregatorRoutedVendorCases() { | |
| // custom-llm hits the same fallback, as it does for perplexity and moonshot. | ||
| Arguments.of("z-ai/glm-4.5", "custom-llm", "0.00104")); | ||
| } | ||
|
|
||
| /** | ||
| * Covers registering {@code replicate} as a canonical provider so that the 40 non-zero-cost | ||
| * entries in {@code model_prices_and_context_window.json} tagged with | ||
| * {@code litellm_provider: "replicate"} are no longer silently dropped at load time. No Replicate | ||
| * model publishes cache rates today, so all Replicate requests route through | ||
| * {@link SpanCostCalculator#textGenerationCost}. | ||
| */ | ||
| @Test | ||
| void calculateCostHandlesReplicateModels() { | ||
| // replicate/openai/o1: input 1.5e-05, output 6e-05 | ||
| // 1000 * 1.5e-05 + 200 * 6e-05 = 0.027 | ||
| BigDecimal cost = CostService.calculateCost("replicate/openai/o1", "replicate", | ||
| Map.of("prompt_tokens", 1000, "completion_tokens", 200), null); | ||
|
|
||
| assertThat(cost).isEqualByComparingTo("0.027"); | ||
| } | ||
|
|
||
| /** | ||
| * Covers registering {@code watsonx} as a canonical provider so that the 28 non-zero-cost | ||
|
Comment on lines
+984
to
+995
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. Duplicated provider cost tests
Want Baz to fix this for you? Activate Fixer Other fix methodsPrompt for AI Agents |
||
| * entries in {@code model_prices_and_context_window.json} tagged with | ||
| * {@code litellm_provider: "watsonx"} are no longer silently dropped at load time. No Watsonx | ||
| * model publishes cache rates today, so all Watsonx requests route through | ||
| * {@link SpanCostCalculator#textGenerationCost}. | ||
| */ | ||
| @Test | ||
| void calculateCostHandlesWatsonxModels() { | ||
| // watsonx/openai/gpt-oss-120b: input 1.5e-07, output 6e-07 | ||
| // 1000 * 1.5e-07 + 200 * 6e-07 = 0.00027 | ||
| BigDecimal cost = CostService.calculateCost("watsonx/openai/gpt-oss-120b", "watsonx", | ||
| Map.of("prompt_tokens", 1000, "completion_tokens", 200), null); | ||
|
|
||
| assertThat(cost).isEqualByComparingTo("0.00027"); | ||
| } | ||
| } | ||
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.
Watsonx transcription costs remain zero
Adding
watsonxtoPROVIDERS_MAPPINGadmitswatsonx/whisper-large-v3-turbo, but itsinput_cost_per_secondandoutput_cost_per_secondfields have no representation inModelCostData, sobuildModelPricecreates zero rates; withmode: audio_transcription,resolveCalculatorfalls through todefaultCost, and publiccalculateCost(..., usage, null)reports zero for non-zero transcription usage. Should we add the per-second fields and a duration-keyed transcription calculator with a regression test, or exclude this model/provider shape fromPROVIDERS_MAPPING?Want Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents