Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[错误]: Claude 3.7 Sonnet 无法使用 128k 的 max_tokens #2877

Open
3 tasks done
chesha1 opened this issue Mar 5, 2025 · 5 comments · May be fixed by #2887
Open
3 tasks done

[错误]: Claude 3.7 Sonnet 无法使用 128k 的 max_tokens #2877

chesha1 opened this issue Mar 5, 2025 · 5 comments · May be fixed by #2887
Labels
bug Something isn't working

Comments

@chesha1
Copy link

chesha1 commented Mar 5, 2025

提交前检查

  • 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决。
  • 我已经查看了置顶 Issue 并搜索了现有的 开放Issue已关闭Issue,没有找到类似的问题。
  • 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等。

平台

macOS

版本

v1.0.5

错误描述

当前的 DEFAULT_MAX_TOKENS 太小,所以打开了开启消息长度限制,并设置为 128000,报错如下:

{
  "message": "400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"max_tokens: 128000 > 64000, which is the maximum allowed number of output tokens for claude-3-7-sonnet-20250219\"}}",
  "status": 400,
  "error": {
    "type": "error",
    "error": {
      "type": "invalid_request_error",
      "message": "max_tokens: 128000 > 64000, which is the maximum allowed number of output tokens for claude-3-7-sonnet-20250219"
    }
  }
}

但是多传递一个 header 就能开启 128k,参考:https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking#extended-output-capabilities-beta

顺便说下,是否考虑过对不同模型启用不同的 DEFAULT_MAX_TOKENS,带 CoT 的模型会消耗很多 token 在思考上,当前的默认值感觉有点限制这些模型的能力了

重现步骤

NOP

预期行为

NOP

相关日志输出

附加信息

No response

@chesha1 chesha1 added the bug Something isn't working label Mar 5, 2025
@DeJeune
Copy link
Collaborator

DeJeune commented Mar 5, 2025

应该是官方API不支持128k吧。之前我调用SDK出错了,把这里代码回滚了。还没测试,如果测试通过下个版本就加上128k的支持

@0xfullex
Copy link
Contributor

0xfullex commented Mar 5, 2025

这不是app的问题,是接口返回的错误信息。

实际上sonnet 3.7的max output 是 8K / Extended thinking: 64000 tokens,如下:
https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-comparison-table

@chesha1
Copy link
Author

chesha1 commented Mar 5, 2025

这不是app的问题,是接口返回的错误信息。

实际上sonnet 3.7的max output 是 8K / Extended thinking: 64000 tokens,如下: https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-comparison-table

这个似乎是正式版的最长限制,beta 版能再长一点,我上面发的链接里有关于 128k max_tokens 的相关说明

@chesha1
Copy link
Author

chesha1 commented Mar 5, 2025

应该是官方API不支持128k吧。之前我调用SDK出错了,把这里代码回滚了。还没测试,如果测试通过下个版本就加上128k的支持

正式版暂时是 64k,beta 版支持到 128k,所以希望软件能把 beta 版需要的 header 加上,或者在检测到用户输入了大于 64k 的 max_tokens 时把 header 带上

@ousugo
Copy link
Collaborator

ousugo commented Mar 5, 2025

应该是官方 API 不支持 128k 吧。之前我调用 SDK 出错了,把这里代码回滚了。还没测试,如果测试通过下个版本就加上 128k 的支持

@DeJeune 我们之前参数加错了,加到 body 里面去了,应该是要加到 header 里面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants