feat: Add Claude extended thinking (#254)

* feat: Add Claude extended thinking
* fix: Set 1.0 temperature for thinking mode
This commit is contained in:
Petr Mironychev
2025-11-12 18:33:15 +01:00
committed by GitHub
parent 89797639cf
commit 161d77ac04
23 changed files with 745 additions and 40 deletions

View File

@ -42,7 +42,33 @@ public:
if (context.history) {
for (const auto &msg : context.history.value()) {
if (msg.role != "system") {
messages.append(QJsonObject{{"role", msg.role}, {"content", msg.content}});
// Handle thinking blocks with structured content
if (msg.isThinking) {
// Create content array with thinking block
QJsonArray content;
QJsonObject thinkingBlock;
thinkingBlock["type"] = msg.isRedacted ? "redacted_thinking" : "thinking";
// Extract actual thinking text (remove display signature)
QString thinkingText = msg.content;
int signaturePos = thinkingText.indexOf("\n[Signature: ");
if (signaturePos != -1) {
thinkingText = thinkingText.left(signaturePos);
}
if (!msg.isRedacted) {
thinkingBlock["thinking"] = thinkingText;
}
if (!msg.signature.isEmpty()) {
thinkingBlock["signature"] = msg.signature;
}
content.append(thinkingBlock);
messages.append(QJsonObject{{"role", "assistant"}, {"content", content}});
} else {
// Normal message
messages.append(QJsonObject{{"role", msg.role}, {"content", msg.content}});
}
}
}
}