Fixing watsonx error: 'model_id' or 'model' cannot be specified in the request body for models in a deployment space

This commit is contained in:
Juan Cruz-Benito 2025-06-18 15:31:50 +02:00
parent 01af7fe1a8
commit 9d16a3000b
2 changed files with 7 additions and 1 deletions

View file

@ -272,7 +272,11 @@ class OpenAILikeChatHandler(OpenAILikeBase):
)
data = {
"model": model,
# watsonx: Deployment models do not support 'model_id' in their payload
# https://github.com/BerriAI/litellm/issues/11837
"model": None
if custom_llm_provider == "watsonx" and model.startswith("deployment/")
else model,
"messages": messages,
**optional_params,
**extra_body,

View file

@ -207,6 +207,7 @@ def test_watsonx_deployment_space_id(monkeypatch, watsonx_chat_completion_call,
assert mock_post.call_count == 1
json_data = json.loads(mock_post.call_args.kwargs["data"])
assert my_fake_space_id not in json_data
assert json_data.get("model") is None
def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_call):
@ -218,3 +219,4 @@ def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_ca
assert mock_post.call_count == 1
json_data = json.loads(mock_post.call_args.kwargs["data"])
assert my_fake_space_id not in json_data
assert json_data.get("model") is None