Expand the output context size when we use Sonnet

This commit is contained in:
Zvonimir Sabljic
2024-07-28 18:49:18 -07:00
parent ceaf55648e
commit 2b9e2d0c3a

View File

@@ -15,6 +15,7 @@ log = get_logger(__name__)
# Maximum number of tokens supported by Anthropic Claude 3
MAX_TOKENS = 4096
MAX_TOKENS_SONNET = 8192
class AnthropicClient(BaseLLMClient):
@@ -72,6 +73,11 @@ class AnthropicClient(BaseLLMClient):
"messages": messages,
"temperature": self.config.temperature if temperature is None else temperature,
}
if "sonnet" in self.config.model:
completion_kwargs["extra_headers"] = {"anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15"}
completion_kwargs["max_tokens"] = MAX_TOKENS_SONNET
if json_mode:
completion_kwargs["response_format"] = {"type": "json_object"}