Skip to content

Commit

Permalink
fix: claude-3-5-sonnet-20240620 max token error (#6843)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouhaoJiang authored Jul 31, 2024
1 parent 77c071e commit df9bd36
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ parameter_rules:
required: false
- name: max_tokens
use_template: max_tokens
required: true
default: 8192
min: 1
max: 8192
Expand Down
3 changes: 2 additions & 1 deletion api/core/model_runtime/model_providers/anthropic/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def _chat_generate(self, model: str, credentials: dict,
# Add the new header for claude-3-5-sonnet-20240620 model
extra_headers = {}
if model == "claude-3-5-sonnet-20240620":
extra_headers["anthropic-beta"] = "max-tokens-3-5-sonnet-2024-07-15"
if model_parameters.get('max_tokens') > 4096:
extra_headers["anthropic-beta"] = "max-tokens-3-5-sonnet-2024-07-15"

if tools:
extra_model_kwargs['tools'] = [
Expand Down

0 comments on commit df9bd36

Please sign in to comment.