Skip to content
Closed
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
11 changes: 9 additions & 2 deletions livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
DEFAULT_TEXT_MODEL = "amazon.nova-2-lite-v1:0"


def _supports_inference_config(model: str) -> bool:
"""Return whether the Bedrock model accepts the common sampling fields."""
# Claude Opus 4.7 removed temperature, top_p, and top_k from its request
# schema. Keep this check substring-based so inference profile ARNs work too.
return "claude-opus-4-7" not in model.lower()


@dataclass
class _LLMOptions:
model: str
Expand Down Expand Up @@ -197,9 +204,9 @@ def _get_tool_config() -> dict[str, Any] | None:
if is_given(self._opts.max_output_tokens):
inference_config["maxTokens"] = self._opts.max_output_tokens
temperature = temperature if is_given(temperature) else self._opts.temperature
if is_given(temperature):
if is_given(temperature) and _supports_inference_config(self._opts.model):
inference_config["temperature"] = temperature
if is_given(self._opts.top_p):
if is_given(self._opts.top_p) and _supports_inference_config(self._opts.model):
inference_config["topP"] = self._opts.top_p

opts["inferenceConfig"] = inference_config
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from livekit.plugins.aws.llm import _supports_inference_config
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

pytestmark = pytest.mark.unit


def test_claude_opus_47_does_not_receive_temperature():
assert not _supports_inference_config("anthropic.claude-opus-4-7-v1:0")
assert not _supports_inference_config(
"arn:aws:bedrock:us-east-1:123456789012:inference-profile/us.anthropic.claude-opus-4-7"
)


def test_claude_opus_47_does_not_receive_top_p():
assert not _supports_inference_config("anthropic.claude-opus-4-7-v1:0")


def test_other_models_keep_temperature_support():
assert _supports_inference_config("anthropic.claude-sonnet-4-20250514-v1:0")