Skip to content
New issue

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

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

Already on GitHub? # to your account

Handle extended thinking with Anthropic provider, process streaming thinking blocks and show them in the output tab #4426

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ferenci84
Copy link
Contributor

@ferenci84 ferenci84 commented Mar 1, 2025

Description

This modification allows users to see the human-readable parts of the thinking blocks in the LLM output.

This simple change is a first step on the way of full implementation of handling thinking blocks.

Checklist

  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

[ For visual changes, include screenshots. ]
Screenshot 2025-03-01 at 14 18 00

Testing instructions

Thinking can be enabled in config this way:

   {
      "title": "Anthropic - Claude 3.7 Sonnet (thinking)",
      "model": "claude-3-7-sonnet-latest",
      "provider": "anthropic",
      "apiKey": "xxx",
      "completionOptions": {
        "temperature": 1,
        "topP": 0.999,
        "maxTokens": 8096
      },
      "requestOptions": {
        "extraBodyProperties": {
          "thinking": {
            "type": "enabled",
            "budget_tokens": 2048
          }
        }
      },
      "cacheBehavior": {
        "cacheConversation": true,
        "cacheSystemMessage": true
      }
    },

Watch the Continue - LLM Prompt/Completion output tab.

Next steps

  1. The thinking mode doesn't currently work with tool use. The software should add the thinking and redacted_thinking blocks to the conversation history when sending subsequent requests. Tool use requires this, with no tool use, any thinking blocks will be ignored.

  2. human-readable thinking blocks could be added to the UI in form of collapsible boxes. This is an example from TypingMind:

Screenshot 2025-03-01 at 14 29 38

Edit

Handling thinking blocks and redacted_thinking blocks have been added. Due to these changes, these thinking blocks have also became visible. This may require some visual update, but it's now accessible and functional, and we are closer to a final solution where users can read the thinking blocks if they want.

Additional testing instructions

The changes are working if you can call tools with no problem.

Redacted thinking can be tested by adding this string in your first prompt:
ANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB

Edit 2

I have added rendering of thinking blocks as shown in the screenshots below:

Screenshot 2025-03-05 at 11 42 56 Screenshot 2025-03-05 at 11 43 05 Screenshot 2025-03-05 at 11 42 33

Copy link

netlify bot commented Mar 1, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 93602e3
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67c82a7750307300085b89a2

@ferenci84 ferenci84 changed the title add ThinkingChatMessage interface and handle thinking chunks in BaseLLM and Anthropic classes Handle extended thinking with Anthropic provider, accept streaming messages and show thinking blocks in the output tab Mar 1, 2025
@ferenci84 ferenci84 changed the title Handle extended thinking with Anthropic provider, accept streaming messages and show thinking blocks in the output tab Handle extended thinking with Anthropic provider, process streaming thinking blocks and show them in the output tab Mar 1, 2025
@chezsmithy
Copy link
Contributor

chezsmithy commented Mar 2, 2025

Would it be possible to add the same support to Bedrock.ts now that I have enabled tools support, and have a seprate PR to enable claude 3.7 on bedrock as well?

@ferenci84
Copy link
Contributor Author

Would it be possible to add the same support to Bedrock.ts now that I have enabled tools support, and have a seprate PR to enable claude 3.7 on bedrock as well?

@chezsmithy I have just sent a PR that does the same with Bedrock: #4444

@Symfomany
Copy link

Deep Research would be a killer-feature in this coding assistant Continue, it's possible to have Perplexity API Key too ?

@ferenci84
Copy link
Contributor Author

@RomneyDa You are the assignee of issue #4339 and this PR would resolve it, can you please review?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants