feat(aistudio): track Gemini usage and improve stream errors

This commit is contained in:
hkfires
2025-10-25 14:45:42 +08:00
parent 3839d93ba0
commit c32e013605
3 changed files with 52 additions and 22 deletions

View File

@@ -203,7 +203,9 @@ func (s *Service) wsOnConnected(provider string) {
}
if s.coreManager != nil {
if existing, ok := s.coreManager.GetByID(provider); ok && existing != nil {
return
if !existing.Disabled && existing.Status == coreauth.StatusActive {
return
}
}
}
now := time.Now().UTC()
@@ -225,6 +227,10 @@ func (s *Service) wsOnDisconnected(provider string, reason error) {
return
}
if reason != nil {
if strings.Contains(reason.Error(), "replaced by new connection") {
log.Infof("websocket provider replaced: %s", provider)
return
}
log.Warnf("websocket provider disconnected: %s (%v)", provider, reason)
} else {
log.Infof("websocket provider disconnected: %s", provider)