litellm/tests/local_testing/test_model_alias_map.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.1 KiB
Python
Raw Normal View History

2023-08-24 23:20:19 +08:00
#### What this tests ####
# This tests the model alias mapping - if user passes in an alias, and has set an alias, set it to the actual value
import os
import sys
2023-08-24 23:20:19 +08:00
import traceback
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
2023-11-16 09:40:15 +08:00
import pytest
2023-08-24 23:20:19 +08:00
import litellm
from litellm import completion, embedding
2023-08-24 23:20:19 +08:00
litellm.set_verbose = True
2025-09-02 08:04:47 +08:00
model_alias_map = {"good-model": "groq/llama-3.1-8b-instant"}
2023-09-02 04:22:16 +08:00
def test_model_alias_map(caplog):
2023-11-16 09:40:15 +08:00
try:
2023-12-13 02:57:51 +08:00
litellm.model_alias_map = model_alias_map
2023-11-16 09:40:15 +08:00
response = completion(
"good-model",
messages=[{"role": "user", "content": "Hey, how's it going?"}],
top_p=0.1,
temperature=0.01,
2023-11-16 10:07:01 +08:00
max_tokens=10,
2023-11-16 09:40:15 +08:00
)
print(response.model)
captured_logs = [rec.levelname for rec in caplog.records]
for log in captured_logs:
assert "ERROR" not in log
2025-09-02 08:59:40 +08:00
assert "llama-3.1-8b-instant" in response.model
2024-08-09 09:54:40 +08:00
except litellm.ServiceUnavailableError:
pass
2023-11-16 09:40:15 +08:00
except Exception as e:
pytest.fail(f"Error occurred: {e}")
2023-12-25 16:40:38 +08:00
# test_model_alias_map()