Skip to content

Comments

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

Merged
aubin-tchoi merged 2 commits intomainfrom
anthropic-delimiters
Mar 19, 2025
Merged

Wrap Claude 3.7 thinking tokens in <thinking> tags#11486
aubin-tchoi merged 2 commits intomainfrom
anthropic-delimiters

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
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
pinotalexandre pushed a commit that referenced this pull request Apr 30, 2025
* add thinking tags at the beginning and end of thinking blocks

* fmt
franckq25655 pushed a commit to jamon8888/dust that referenced this pull request May 13, 2025
* add thinking tags at the beginning and end of thinking blocks

* fmt
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