mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
refactor(cache, translator): remove session ID from signature caching and clean up logic
This commit is contained in:
8
internal/cache/signature_cache.go
vendored
8
internal/cache/signature_cache.go
vendored
@@ -104,9 +104,9 @@ func CacheSignature(modelName, text, signature string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sc := getOrCreateSession(fmt.Sprintf("%s#%s", GetModelGroup(modelName), text))
|
text = fmt.Sprintf("%s#%s", GetModelGroup(modelName), text)
|
||||||
textHash := hashText(text)
|
textHash := hashText(text)
|
||||||
|
sc := getOrCreateSession(textHash)
|
||||||
sc.mu.Lock()
|
sc.mu.Lock()
|
||||||
defer sc.mu.Unlock()
|
defer sc.mu.Unlock()
|
||||||
|
|
||||||
@@ -127,8 +127,8 @@ func GetCachedSignature(modelName, text string) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
text = fmt.Sprintf("%s#%s", GetModelGroup(modelName), text)
|
||||||
val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", family, text))
|
val, ok := signatureCache.Load(hashText(text))
|
||||||
if !ok {
|
if !ok {
|
||||||
if family == "gemini" {
|
if family == "gemini" {
|
||||||
return "skip_thought_signature_validator"
|
return "skip_thought_signature_validator"
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ type Params struct {
|
|||||||
HasContent bool // Tracks whether any content (text, thinking, or tool use) has been output
|
HasContent bool // Tracks whether any content (text, thinking, or tool use) has been output
|
||||||
|
|
||||||
// Signature caching support
|
// Signature caching support
|
||||||
SessionID string // Session ID derived from request for signature caching
|
|
||||||
CurrentThinkingText strings.Builder // Accumulates thinking text for signature caching
|
CurrentThinkingText strings.Builder // Accumulates thinking text for signature caching
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ func ConvertAntigravityResponseToClaude(_ context.Context, _ string, originalReq
|
|||||||
if thoughtSignature := partResult.Get("thoughtSignature"); thoughtSignature.Exists() && thoughtSignature.String() != "" {
|
if thoughtSignature := partResult.Get("thoughtSignature"); thoughtSignature.Exists() && thoughtSignature.String() != "" {
|
||||||
// log.Debug("Branch: signature_delta")
|
// log.Debug("Branch: signature_delta")
|
||||||
|
|
||||||
if params.SessionID != "" && params.CurrentThinkingText.Len() > 0 {
|
if params.CurrentThinkingText.Len() > 0 {
|
||||||
cache.CacheSignature(modelName, params.CurrentThinkingText.String(), thoughtSignature.String())
|
cache.CacheSignature(modelName, params.CurrentThinkingText.String(), thoughtSignature.String())
|
||||||
// log.Debugf("Cached signature for thinking block (sessionID=%s, textLen=%d)", params.SessionID, params.CurrentThinkingText.Len())
|
// log.Debugf("Cached signature for thinking block (sessionID=%s, textLen=%d)", params.SessionID, params.CurrentThinkingText.Len())
|
||||||
params.CurrentThinkingText.Reset()
|
params.CurrentThinkingText.Reset()
|
||||||
|
|||||||
Reference in New Issue
Block a user