Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class AnthropicChatGenerator:
"top_k",
"extra_headers",
"thinking",
"output_config",
]

def __init__(
Expand Down Expand Up @@ -144,6 +145,7 @@ def __init__(
- `thinking`: A dictionary of thinking parameters to be passed to the model.
The `budget_tokens` passed for thinking should be less than `max_tokens`.
For more details and supported models, see: [Anthropic Extended Thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
- `output_config`: A dictionary of output configuration options to be passed to the model.

:param ignore_tools_thinking_messages: Anthropic's approach to tools (function calling) resolution involves a
"chain of thought" messages before returning the actual function names and parameters in a message. If
Expand Down
14 changes: 14 additions & 0 deletions integrations/anthropic/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ def test_run_with_params(self, chat_messages, mock_anthropic_completion):
assert response["replies"][0].meta["model"] == "claude-sonnet-4-5"
assert response["replies"][0].meta["finish_reason"] == "stop"

def test_run_with_output_config(self, chat_messages, mock_anthropic_completion):
"""
Test that output_config is passed to the Anthropic API.
"""
output_config = {"effort": "medium"}
component = AnthropicChatGenerator(
api_key=Secret.from_token("test-api-key"),
generation_kwargs={"max_tokens": 10, "output_config": output_config},
)
component.run(chat_messages)

_, kwargs = mock_anthropic_completion.call_args
assert kwargs["output_config"] == output_config

@pytest.mark.parametrize(
"generation_kwargs,expected_kwargs",
[
Expand Down