Signature handling for fallback

This commit is contained in:
Badri Narayanan S
2026-01-03 22:01:57 +05:30
parent df6625b531
commit ac9ec6b358
8 changed files with 618 additions and 24 deletions

View File

@@ -4,8 +4,8 @@
*/
import crypto from 'crypto';
import { MIN_SIGNATURE_LENGTH } from '../constants.js';
import { cacheSignature } from './signature-cache.js';
import { MIN_SIGNATURE_LENGTH, getModelFamily } from '../constants.js';
import { cacheSignature, cacheThinkingSignature } from './signature-cache.js';
/**
* Convert Google Generative AI response to Anthropic Messages API format
@@ -33,6 +33,12 @@ export function convertGoogleToAnthropic(googleResponse, model) {
if (part.thought === true) {
const signature = part.thoughtSignature || '';
// Cache thinking signature with model family for cross-model compatibility
if (signature && signature.length >= MIN_SIGNATURE_LENGTH) {
const modelFamily = getModelFamily(model);
cacheThinkingSignature(signature, modelFamily);
}
// Include thinking blocks in the response for Claude Code
anthropicContent.push({
type: 'thinking',