-
-
Notifications
You must be signed in to change notification settings - Fork 353
Add Extended Thinking and Extended Output for Claude 3.7 #998
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
Conversation
|
This looks great, thank you. A couple of suggestions:
extended_output = {
order = 2,
mapping = "parameters",
type = "boolean",
optional = true,
default = false,
condition = function(schema)
local model = schema.model.default
if schema.model.choices[model] and schema.model.choices[model].opts then
return schema.model.choices[model].opts.can_reason
end
end,
desc = "Enable larger output context (128k tokens). Only available with claude-3-7-sonnet-20250219.",
},
You could set |
|
Added |
|
@bashtoni I've just pushed a fix to the main branch (and updated this PR in the process). This has allowed me to do some clever manipulation of {
"system": [
{
"text": "You are an AI programming assistant named \"CodeCompanion\". You are currently plugged into the Neovim text editor on a user's machine.\n\nYour core tasks include:\n- Answering general programming questions.\n- Explaining how the code in a Neovim buffer works.\n- Reviewing the selected code in a Neovim buffer.\n- Generating unit tests for the selected code.\n- Proposing fixes for problems in the selected code.\n- Scaffolding code for a new workspace.\n- Finding relevant code to the user's query.\n- Proposing fixes for test failures.\n- Answering questions about Neovim.\n- Running tools.\n\nYou must:\n- Follow the user's requirements carefully and to the letter.\n- Keep your answers short and impersonal, especially if the user's context is outside your core tasks.\n- Minimize additional prose unless clarification is needed.\n- Use Markdown formatting in your answers.\n- Include the programming language name at the start of each Markdown code block.\n- Avoid including line numbers in code blocks.\n- Avoid wrapping the whole response in triple backticks.\n- Only return code that's directly relevant to the task at hand. You may omit code that isn’t necessary for the solution.\n- Use actual line breaks in your responses; only use \"\\n\" when you want a literal backslash followed by 'n'.\n- All non-code text responses must be written in the English language indicated.\n\nWhen given a task:\n1. Think step-by-step and, unless the user requests otherwise or the task is very simple, describe your plan in detailed pseudocode.\n2. Output the final code in a single code block, ensuring that only relevant code is included.\n3. End your response with a short suggestion for the next user turn that directly supports continuing the conversation.\n4. Provide exactly one complete reply per conversation turn.",
"cache_control": {
"type": "ephemeral"
},
"type": "text"
}
],
"messages": [
{
"role": "user",
"content": "Can you show me some Ruby code?"
}
],
"stream": true,
"temperature": 1,
"max_tokens": 17000,
"thinking": {
"budget_tokens": 16000,
"type": "enabled"
},
"model": "claude-3-7-sonnet-20250219"
} |
|
And added one final fix. If you fix the reasoning header and give this a test, I think we're good to merge! |
|
All seems to be good now. Fantastic job on this @bashtoni, a great addition to the plugin. |
|
@olimorris can this also be enabled for the copilot adapter somehow? Is adding |
|
@gstokkink see #1001 |
…3.7 (olimorris#998) * Add Extended Thinking and Extended Output for Cladue 3.7 * Add `can_reason` to model as suggested * Claude 3.7 supports 128k tokens with extended output * Update anthropic.lua for use of temp table and max tokens error * fix: do not overwrite headers --------- Co-authored-by: Oli <[email protected]>

Description
Claude 3.7 adds DeepSeek R1-like 'extended thinking' - see https://www.anthropic.com/news/visible-extended-thinking
This PR adds support for this, and also extended output.
Like the DeepSeek plugin, it outputs the 'thinking' text when streaming.
One thing I'd appreciate feedback on. I've added parameters that don't directly map to API parameters, which I then set to nil later once we've built the actual params/header required. Is there a better way to do this?
Checklist
make docsto update the vimdoc pages