mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(translator): enhance signature cache clearing logic and update test cases with model name
This commit is contained in:
8
internal/cache/signature_cache.go
vendored
8
internal/cache/signature_cache.go
vendored
@@ -156,7 +156,13 @@ func GetCachedSignature(modelName, sessionID, text string) string {
|
|||||||
// ClearSignatureCache clears signature cache for a specific session or all sessions.
|
// ClearSignatureCache clears signature cache for a specific session or all sessions.
|
||||||
func ClearSignatureCache(sessionID string) {
|
func ClearSignatureCache(sessionID string) {
|
||||||
if sessionID != "" {
|
if sessionID != "" {
|
||||||
signatureCache.Delete(sessionID)
|
signatureCache.Range(func(key, _ any) bool {
|
||||||
|
kStr, ok := key.(string)
|
||||||
|
if ok && strings.HasSuffix(kStr, "#"+sessionID) {
|
||||||
|
signatureCache.Delete(key)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
signatureCache.Range(func(key, _ any) bool {
|
signatureCache.Range(func(key, _ any) bool {
|
||||||
signatureCache.Delete(key)
|
signatureCache.Delete(key)
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ func TestConvertAntigravityResponseToClaude_SignatureCached(t *testing.T) {
|
|||||||
cache.ClearSignatureCache("")
|
cache.ClearSignatureCache("")
|
||||||
|
|
||||||
requestJSON := []byte(`{
|
requestJSON := []byte(`{
|
||||||
|
"model": "claude-sonnet-4-5-thinking",
|
||||||
"messages": [{"role": "user", "content": [{"type": "text", "text": "Cache test"}]}]
|
"messages": [{"role": "user", "content": [{"type": "text", "text": "Cache test"}]}]
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
@@ -158,6 +159,7 @@ func TestConvertAntigravityResponseToClaude_MultipleThinkingBlocks(t *testing.T)
|
|||||||
cache.ClearSignatureCache("")
|
cache.ClearSignatureCache("")
|
||||||
|
|
||||||
requestJSON := []byte(`{
|
requestJSON := []byte(`{
|
||||||
|
"model": "claude-sonnet-4-5-thinking",
|
||||||
"messages": [{"role": "user", "content": [{"type": "text", "text": "Multi block test"}]}]
|
"messages": [{"role": "user", "content": [{"type": "text", "text": "Multi block test"}]}]
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user