hkfires commited on
Commit ·
be02664
1
Parent(s): e5d4238
fix(translator): enhance signature cache clearing logic and update test cases with model name
Browse files
internal/cache/signature_cache.go
CHANGED
|
@@ -156,7 +156,13 @@ func GetCachedSignature(modelName, sessionID, text string) string {
|
|
| 156 |
// ClearSignatureCache clears signature cache for a specific session or all sessions.
|
| 157 |
func ClearSignatureCache(sessionID string) {
|
| 158 |
if sessionID != "" {
|
| 159 |
-
signatureCache.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
} else {
|
| 161 |
signatureCache.Range(func(key, _ any) bool {
|
| 162 |
signatureCache.Delete(key)
|
|
|
|
| 156 |
// ClearSignatureCache clears signature cache for a specific session or all sessions.
|
| 157 |
func ClearSignatureCache(sessionID string) {
|
| 158 |
if sessionID != "" {
|
| 159 |
+
signatureCache.Range(func(key, _ any) bool {
|
| 160 |
+
kStr, ok := key.(string)
|
| 161 |
+
if ok && strings.HasSuffix(kStr, "#"+sessionID) {
|
| 162 |
+
signatureCache.Delete(key)
|
| 163 |
+
}
|
| 164 |
+
return true
|
| 165 |
+
})
|
| 166 |
} else {
|
| 167 |
signatureCache.Range(func(key, _ any) bool {
|
| 168 |
signatureCache.Delete(key)
|
internal/translator/antigravity/claude/antigravity_claude_response_test.go
CHANGED
|
@@ -97,6 +97,7 @@ func TestConvertAntigravityResponseToClaude_SignatureCached(t *testing.T) {
|
|
| 97 |
cache.ClearSignatureCache("")
|
| 98 |
|
| 99 |
requestJSON := []byte(`{
|
|
|
|
| 100 |
"messages": [{"role": "user", "content": [{"type": "text", "text": "Cache test"}]}]
|
| 101 |
}`)
|
| 102 |
|
|
@@ -158,6 +159,7 @@ func TestConvertAntigravityResponseToClaude_MultipleThinkingBlocks(t *testing.T)
|
|
| 158 |
cache.ClearSignatureCache("")
|
| 159 |
|
| 160 |
requestJSON := []byte(`{
|
|
|
|
| 161 |
"messages": [{"role": "user", "content": [{"type": "text", "text": "Multi block test"}]}]
|
| 162 |
}`)
|
| 163 |
|
|
|
|
| 97 |
cache.ClearSignatureCache("")
|
| 98 |
|
| 99 |
requestJSON := []byte(`{
|
| 100 |
+
"model": "claude-sonnet-4-5-thinking",
|
| 101 |
"messages": [{"role": "user", "content": [{"type": "text", "text": "Cache test"}]}]
|
| 102 |
}`)
|
| 103 |
|
|
|
|
| 159 |
cache.ClearSignatureCache("")
|
| 160 |
|
| 161 |
requestJSON := []byte(`{
|
| 162 |
+
"model": "claude-sonnet-4-5-thinking",
|
| 163 |
"messages": [{"role": "user", "content": [{"type": "text", "text": "Multi block test"}]}]
|
| 164 |
}`)
|
| 165 |
|