Skip to content
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

fix(main.py): fix passing openrouter specific params #8184

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion litellm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,7 @@ def completion( # type: ignore # noqa: PLR0915
data = {"model": model, "messages": messages, **optional_params}

## COMPLETION CALL
response = openai_chat_completions.completion(
response = openai_like_chat_completion.completion(
model=model,
messages=messages,
headers=headers,
Expand All @@ -2221,6 +2221,8 @@ def completion( # type: ignore # noqa: PLR0915
acompletion=acompletion,
timeout=timeout, # type: ignore
custom_llm_provider="openrouter",
custom_prompt_dict=custom_prompt_dict,
encoding=encoding,
)
## LOGGING
logging.post_call(
Expand Down
11 changes: 11 additions & 0 deletions litellm/model_prices_and_context_window_backup.json
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,17 @@
"output_cost_per_second": 0.0001,
"litellm_provider": "azure"
},
"azure/deepseek-r1": {
"max_tokens": 8192,
"max_input_tokens": 128000,
"max_output_tokens": 8192,
"input_cost_per_token": 0.0,
"input_cost_per_token_cache_hit": 0.0,
"output_cost_per_token": 0.0,
"litellm_provider": "azure",
"mode": "chat",
"supports_prompt_caching": true
},
"azure/o3-mini": {
"max_tokens": 100000,
"max_input_tokens": 200000,
Expand Down
15 changes: 15 additions & 0 deletions tests/local_testing/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,21 @@ def test_completion_openrouter1():
pytest.fail(f"Error occurred: {e}")


def test_completion_openrouter_reasoning_effort():
try:
litellm.set_verbose = True
response = completion(
model="openrouter/deepseek/deepseek-r1",
messages=messages,
include_reasoning=True,
max_tokens=5,
)
# Add any assertions here to check the response
print(response)
except Exception as e:
pytest.fail(f"Error occurred: {e}")


# test_completion_openrouter1()


Expand Down
21 changes: 21 additions & 0 deletions tests/local_testing/test_get_model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,24 @@ def test_get_model_info_huggingface_models(monkeypatch):
providers=["huggingface"],
**info,
)


@pytest.mark.parametrize(
"model, provider",
[
("bedrock/us-east-2/us.anthropic.claude-3-haiku-20240307-v1:0", None),
(
"bedrock/us-east-2/us.anthropic.claude-3-haiku-20240307-v1:0",
"bedrock",
),
],
)
def test_get_model_info_cost_calculator_bedrock_region_cris_stripped(model, provider):
"""
ensure cross region inferencing model is used correctly
Relevant Issue: https://github.com/BerriAI/litellm/issues/8115
"""
info = get_model_info(model=model, custom_llm_provider=provider)
print("info", info)
assert info["key"] == "us.anthropic.claude-3-haiku-20240307-v1:0"
assert info["litellm_provider"] == "bedrock"