feat(llm): added Claude Opus 4.5 model and corresponding test (#11841)

This commit is contained in:
adshrc
2025-12-01 12:09:33 +01:00
committed by GitHub
parent 6d8cca43a8
commit 991f1a242c
3 changed files with 25 additions and 3 deletions

View File

@@ -1255,6 +1255,25 @@ def test_opus_41_keeps_temperature_top_p(mock_completion):
assert 'top_p' not in call_kwargs
@patch('openhands.llm.llm.litellm_completion')
def test_opus_45_keeps_temperature_drops_top_p(mock_completion):
mock_completion.return_value = {
'choices': [{'message': {'content': 'ok'}}],
}
config = LLMConfig(
model='anthropic/claude-opus-4-5-20251101',
api_key='k',
temperature=0.7,
top_p=0.9,
)
llm = LLM(config, service_id='svc')
llm.completion(messages=[{'role': 'user', 'content': 'hi'}])
call_kwargs = mock_completion.call_args[1]
assert call_kwargs.get('temperature') == 0.7
# Anthropic rejects both temperature and top_p together on Opus 4.5; we keep temperature and drop top_p
assert 'top_p' not in call_kwargs
@patch('openhands.llm.llm.litellm_completion')
def test_sonnet_4_keeps_temperature_drops_top_p(mock_completion):
mock_completion.return_value = {