lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

[Request] Support for 8192 Output Tokens for Anthropic API

Open pixelbreeze38 opened this issue 1 year ago • 3 comments

🥰 Feature Description

Hello,

I noticed that the current implementation of the Anthropic API client doesn’t support the 8192 output tokens feature. According to the Anthropic documentation, this feature is in beta and requires the header anthropic-beta: max-tokens-3-5-sonnet-2024-07-15. If this header isn’t specified, the limit defaults to 4096 tokens.

🧐 Proposed Solution

To address this, I’ve made a local change that allows the use of 8192 tokens. The update involves modifying the Anthropic client initialization to include the required header.

Changes Made:

In the file src/libs/agent-runtime/anthropic/index.ts, I modified the client initialization as follows:

this.client = new Anthropic({
  apiKey,
  baseURL,
  defaultHeaders: { "anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15" },
});

This change sets the defaultHeaders property to include the necessary beta header, which enables the extended output token limit.

📝 Additional Information

To ensure that users are aware of the beta status of the extended output token limit, it would be helpful to include a disclaimer such as:

Claude 3.5 Sonnet supports max tokens up to 8192 with a beta header. More Info

pixelbreeze38 avatar Jul 26 '24 17:07 pixelbreeze38

👀 @pixelbreeze38

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot avatar Jul 26 '24 17:07 lobehubbot

Maybe you should just submit a PR :)

RubuJam avatar Jul 27 '24 07:07 RubuJam

@pixelbreeze38 PR welcome~

arvinxx avatar Aug 06 '24 02:08 arvinxx

✅ @pixelbreeze38

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

lobehubbot avatar Sep 01 '24 04:09 lobehubbot

:tada: This issue has been resolved in version 1.15.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

lobehubbot avatar Sep 01 '24 04:09 lobehubbot

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Oct 01 '25 01:10 github-actions[bot]