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

Wrap Claude 3.7 thinking tokens in <thinking> tags #11486

Merged
merged 2 commits into from
Mar 19, 2025

Conversation

aubin-tchoi
Copy link
Contributor

@aubin-tchoi aubin-tchoi commented Mar 19, 2025

Description

Before/After

Screenshot 2025-03-19 at 6 08 37 PM Screenshot 2025-03-19 at 6 08 51 PM

Tests

  • Tested locally.

Risk

  • Risk of breaking the display of the CoTs.

Deploy Plan

  • Deploy core.

@aubin-tchoi aubin-tchoi requested a review from spolu March 19, 2025 17:07
@@ -1127,6 +1127,14 @@ impl AnthropicLLM {
StreamContent::AnthropicStreamThinking(
thinking,
) => {
// Send <thinking> tag at the start of a thinking block
let _ = event_sender.send(json!({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't you sending one at each event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at each new thinking block only it would seem (side note: trying out an AI agent tool here, launched the agent, tested, opened the PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i get multiple thinking blocks I separate them nicely in <thinking> elements I think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't we getting such events per token? or token group?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it's a group of token with content_block_start as the event_type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is can we get multiple in a row? If not which is your argument here we should just wrap here instead of the extra logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can't, we're supposed to get a block start then deltas then a block stop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I hadn't seen the name of the event up top. 👍

Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aubin-tchoi aubin-tchoi merged commit fc23511 into main Mar 19, 2025
8 checks passed
@aubin-tchoi aubin-tchoi deleted the anthropic-delimiters branch March 19, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants