Skip to content

Commit d2df5bf

Browse files
committed
fix: remove recursive call
1 parent 6f11137 commit d2df5bf

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

litellm/llms/together_ai/chat.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from typing import Optional
1010

11-
from litellm import get_model_info, verbose_logger
11+
from litellm import verbose_logger
12+
from litellm.utils import get_model_param_support
1213

1314
from ..openai.chat.gpt_transformation import OpenAIGPTConfig
1415

@@ -22,9 +23,8 @@ def get_supported_openai_params(self, model: str) -> list:
2223
"""
2324
supports_function_calling: Optional[bool] = None
2425
try:
25-
model_info = get_model_info(model, custom_llm_provider="together_ai")
26-
supports_function_calling = model_info.get(
27-
"supports_function_calling", False
26+
supports_function_calling = get_model_param_support(
27+
model, "supports_function_calling", custom_llm_provider="together_ai"
2828
)
2929
except Exception as e:
3030
verbose_logger.debug(f"Error getting supported openai params: {e}")

litellm/model_prices_and_context_window_backup.json

+17-12
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@
19561956
},
19571957
"mistral/open-mixtral-8x22b": {
19581958
"max_tokens": 8191,
1959-
"max_input_tokens": 64000,
1959+
"max_input_tokens": 65336,
19601960
"max_output_tokens": 8191,
19611961
"input_cost_per_token": 0.000002,
19621962
"output_cost_per_token": 0.000006,
@@ -2038,7 +2038,7 @@
20382038
},
20392039
"deepseek/deepseek-reasoner": {
20402040
"max_tokens": 8192,
2041-
"max_input_tokens": 64000,
2041+
"max_input_tokens": 65536,
20422042
"max_output_tokens": 8192,
20432043
"input_cost_per_token": 0.00000055,
20442044
"input_cost_per_token_cache_hit": 0.00000014,
@@ -2051,9 +2051,9 @@
20512051
"supports_prompt_caching": true
20522052
},
20532053
"deepseek/deepseek-chat": {
2054-
"max_tokens": 4096,
2055-
"max_input_tokens": 128000,
2056-
"max_output_tokens": 4096,
2054+
"max_tokens": 8192,
2055+
"max_input_tokens": 65536,
2056+
"max_output_tokens": 8192,
20572057
"input_cost_per_token": 0.00000014,
20582058
"input_cost_per_token_cache_hit": 0.000000014,
20592059
"cache_read_input_token_cost": 0.000000014,
@@ -3064,7 +3064,8 @@
30643064
"supports_function_calling": true,
30653065
"supports_tool_choice": true,
30663066
"supports_response_schema": true,
3067-
"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-1.5-pro"
3067+
"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-1.5-pro",
3068+
"deprecation_date": "2025-09-24"
30683069
},
30693070
"gemini-1.5-pro-001": {
30703071
"max_tokens": 8192,
@@ -3265,7 +3266,9 @@
32653266
"supports_function_calling": true,
32663267
"supports_vision": true,
32673268
"supports_response_schema": true,
3268-
"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-1.5-flash"
3269+
"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-1.5-flash",
3270+
"deprecation_date": "2025-09-24",
3271+
"deprecation_date": "2025-09-24"
32693272
},
32703273
"gemini-1.5-flash-001": {
32713274
"max_tokens": 8192,
@@ -4128,7 +4131,8 @@
41284131
"supports_prompt_caching": true,
41294132
"tpm": 4000000,
41304133
"rpm": 2000,
4131-
"source": "https://ai.google.dev/pricing"
4134+
"source": "https://ai.google.dev/pricing",
4135+
"deprecation_date": "2025-09-24"
41324136
},
41334137
"gemini/gemini-1.5-flash-001": {
41344138
"max_tokens": 8192,
@@ -4412,7 +4416,8 @@
44124416
"supports_prompt_caching": true,
44134417
"tpm": 4000000,
44144418
"rpm": 1000,
4415-
"source": "https://ai.google.dev/pricing"
4419+
"source": "https://ai.google.dev/pricing",
4420+
"deprecation_date": "2025-09-24"
44164421
},
44174422
"gemini/gemini-1.5-pro-001": {
44184423
"max_tokens": 8192,
@@ -4837,7 +4842,7 @@
48374842
},
48384843
"openrouter/deepseek/deepseek-r1": {
48394844
"max_tokens": 8192,
4840-
"max_input_tokens": 64000,
4845+
"max_input_tokens": 65336,
48414846
"max_output_tokens": 8192,
48424847
"input_cost_per_token": 0.00000055,
48434848
"input_cost_per_token_cache_hit": 0.00000014,
@@ -4851,8 +4856,8 @@
48514856
},
48524857
"openrouter/deepseek/deepseek-chat": {
48534858
"max_tokens": 8192,
4854-
"max_input_tokens": 66000,
4855-
"max_output_tokens": 4096,
4859+
"max_input_tokens": 65536,
4860+
"max_output_tokens": 8192,
48564861
"input_cost_per_token": 0.00000014,
48574862
"output_cost_per_token": 0.00000028,
48584863
"litellm_provider": "openrouter",

litellm/utils.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ def _custom_logger_class_exists_in_failure_callbacks(
419419
def function_setup( # noqa: PLR0915
420420
original_function: str, rules_obj, start_time, *args, **kwargs
421421
): # just run once to check if user wants to send their data anywhere - PostHog/Sentry/Slack/etc.
422-
423422
### NOTICES ###
424423
from litellm import Logging as LiteLLMLogging
425424
from litellm.litellm_core_utils.litellm_logging import set_callbacks
@@ -4216,7 +4215,6 @@ def _get_model_info_helper( # noqa: PLR0915
42164215
):
42174216
_model_info = None
42184217
if _model_info is None and model in litellm.model_cost:
4219-
42204218
key = model
42214219
_model_info = _get_model_info_from_model_cost(key=key)
42224220
if not _check_provider_match(
@@ -4227,23 +4225,20 @@ def _get_model_info_helper( # noqa: PLR0915
42274225
_model_info is None
42284226
and combined_stripped_model_name in litellm.model_cost
42294227
):
4230-
42314228
key = combined_stripped_model_name
42324229
_model_info = _get_model_info_from_model_cost(key=key)
42334230
if not _check_provider_match(
42344231
model_info=_model_info, custom_llm_provider=custom_llm_provider
42354232
):
42364233
_model_info = None
42374234
if _model_info is None and stripped_model_name in litellm.model_cost:
4238-
42394235
key = stripped_model_name
42404236
_model_info = _get_model_info_from_model_cost(key=key)
42414237
if not _check_provider_match(
42424238
model_info=_model_info, custom_llm_provider=custom_llm_provider
42434239
):
42444240
_model_info = None
42454241
if _model_info is None and split_model in litellm.model_cost:
4246-
42474242
key = split_model
42484243
_model_info = _get_model_info_from_model_cost(key=key)
42494244
if not _check_provider_match(
@@ -4362,6 +4357,25 @@ def _get_model_info_helper( # noqa: PLR0915
43624357
)
43634358

43644359

4360+
def get_model_param_support(
4361+
model: str, param: str, custom_llm_provider: Optional[str]
4362+
) -> bool:
4363+
model_info = litellm.model_cost.get(model)
4364+
potential_model_names = _get_potential_model_names(
4365+
model=model, custom_llm_provider=custom_llm_provider
4366+
)
4367+
4368+
verbose_logger.debug(
4369+
f"checking potential_model_names in litellm.model_cost: {potential_model_names}"
4370+
)
4371+
# iterate over potential model names to get the model cost
4372+
for key, value in potential_model_names.items():
4373+
if value in litellm.model_cost and key != "custom_llm_provider":
4374+
return litellm.model_cost[value].get(param, False)
4375+
4376+
return False
4377+
4378+
43654379
def get_model_info(model: str, custom_llm_provider: Optional[str] = None) -> ModelInfo:
43664380
"""
43674381
Get a dict for the maximum tokens (context window), input_cost_per_token, output_cost_per_token for a given model.

0 commit comments

Comments
 (0)