Conversation
08f795e to
92894d8
Compare
Adds support for anthropic extended thinking. Messages are now parsed into content objects with a list of blocks, instead of a string for content. This is a common openai based format, so existing providers work as normal. Thinking / redacted thinking blocks are represented as blocks within markup tags. The signature is a property as a closing tag, which is a bit odd. This was done to make it easy to support streaming (the signature comes at the end of the message). Redacted thinking is also supported. Redacted thinking doesn't have a signature (because the content is encrypted, so it's already tamper proof).
|
Thanks for the PR! Changing message content to blocks is a good direction, I'd avoided it for simplicity at the start - now it'll break in places where the final request is built by just concatenating with There's a lot of anthropic specific code that made it into I've also been avoiding letting anything that might be part of the normal response have special meaning in mchat, though it'll never be fool-proof due to needing to roundtrip to plaintext. XML tags should be avoided though since those are pretty common in responses. I went with a git conflict-marker inspired for each special block. This also lets the tree-sitter grammar recognize these as foldable and can be styled differently (though I've hardcoded |
|
Oops! Sorry I added some commits here meant for main, we can just squash when merging. Are you still interested in this PR? If not I can fix up the comments and get this merged. |
Adds support for anthropic extended thinking.
Messages are now parsed into content objects with a list of blocks, instead of a string for content. This is a common openai based format, so existing providers work as normal.
Thinking / redacted thinking blocks are represented as blocks within markup tags. The signature is a property as a closing tag, which is a bit odd. This was done to make it easy to support streaming (the signature comes at the end of the message).
Redacted thinking is also supported. Redacted thinking doesn't have a signature (because the content is encrypted, so it's already tamper proof).
Here's an mchat with extended thinking for example: