mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/providers"
|
|
)
|
|
|
|
func formatProcessingError(err error) string {
|
|
if err == nil {
|
|
return ""
|
|
}
|
|
|
|
if kind, ok := providers.ClassifyAuthError(err); ok {
|
|
return fmt.Sprintf(
|
|
"Error processing message: %s\n\nOriginal error:\n%s",
|
|
authErrorFriendlyMessage(kind),
|
|
err.Error(),
|
|
)
|
|
}
|
|
|
|
return fmt.Sprintf("Error processing message: %v", err)
|
|
}
|
|
|
|
func authErrorFriendlyMessage(kind providers.AuthErrorKind) string {
|
|
switch kind {
|
|
case providers.AuthErrorInvalidAPIKey:
|
|
return "Authentication failed: the API key appears to be invalid. Check the API key configured for this model or provider."
|
|
case providers.AuthErrorMissingAPIKey:
|
|
return "Authentication failed: no API key is configured for this model or provider. Add an API key in the model settings or config."
|
|
case providers.AuthErrorExpiredToken:
|
|
return "Authentication failed: the saved login or token appears to be expired. Re-authenticate the provider."
|
|
default:
|
|
return "Authentication failed: check the API key, token, OAuth login, or provider permissions for this model."
|
|
}
|
|
}
|