mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
feat(cache): handle gemini family in signature cache with fallback validator logic
This commit is contained in:
16
internal/cache/signature_cache.go
vendored
16
internal/cache/signature_cache.go
vendored
@@ -119,12 +119,20 @@ func CacheSignature(modelName, sessionID, text, signature string) {
|
|||||||
// GetCachedSignature retrieves a cached signature for a given session and text.
|
// GetCachedSignature retrieves a cached signature for a given session and text.
|
||||||
// Returns empty string if not found or expired.
|
// Returns empty string if not found or expired.
|
||||||
func GetCachedSignature(modelName, sessionID, text string) string {
|
func GetCachedSignature(modelName, sessionID, text string) string {
|
||||||
|
family := GetModelGroup(modelName)
|
||||||
|
|
||||||
if sessionID == "" || text == "" {
|
if sessionID == "" || text == "" {
|
||||||
|
if family == "gemini" {
|
||||||
|
return "skip_thought_signature_validator"
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", GetModelGroup(modelName), sessionID))
|
val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", family, sessionID))
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if family == "gemini" {
|
||||||
|
return "skip_thought_signature_validator"
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
sc := val.(*sessionCache)
|
sc := val.(*sessionCache)
|
||||||
@@ -137,11 +145,17 @@ func GetCachedSignature(modelName, sessionID, text string) string {
|
|||||||
entry, exists := sc.entries[textHash]
|
entry, exists := sc.entries[textHash]
|
||||||
if !exists {
|
if !exists {
|
||||||
sc.mu.Unlock()
|
sc.mu.Unlock()
|
||||||
|
if family == "gemini" {
|
||||||
|
return "skip_thought_signature_validator"
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if now.Sub(entry.Timestamp) > SignatureCacheTTL {
|
if now.Sub(entry.Timestamp) > SignatureCacheTTL {
|
||||||
delete(sc.entries, textHash)
|
delete(sc.entries, textHash)
|
||||||
sc.mu.Unlock()
|
sc.mu.Unlock()
|
||||||
|
if family == "gemini" {
|
||||||
|
return "skip_thought_signature_validator"
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user