mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
- replace legacy DeepSeek ids with the new deepseek-v4 model family\n- move thinking control to request parameters and preserve assistant reasoning content\n- switch history split to IGNORE transcript injection and map upload auth failures to 401\n- update admin defaults, API docs, samples, and tests for the new model scheme
47 lines
956 B
Go
47 lines
956 B
Go
package deepseek
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type FailureKind string
|
|
|
|
const (
|
|
FailureUnknown FailureKind = ""
|
|
FailureDirectUnauthorized FailureKind = "direct_unauthorized"
|
|
FailureManagedUnauthorized FailureKind = "managed_unauthorized"
|
|
)
|
|
|
|
type RequestFailure struct {
|
|
Op string
|
|
Kind FailureKind
|
|
Message string
|
|
}
|
|
|
|
func (e *RequestFailure) Error() string {
|
|
if e == nil {
|
|
return ""
|
|
}
|
|
switch {
|
|
case e.Op != "" && e.Message != "":
|
|
return fmt.Sprintf("%s: %s", e.Op, e.Message)
|
|
case e.Op != "":
|
|
return e.Op + " failed"
|
|
case e.Message != "":
|
|
return e.Message
|
|
default:
|
|
return "request failed"
|
|
}
|
|
}
|
|
|
|
func IsManagedUnauthorizedError(err error) bool {
|
|
var failure *RequestFailure
|
|
return errors.As(err, &failure) && failure.Kind == FailureManagedUnauthorized
|
|
}
|
|
|
|
func IsDirectUnauthorizedError(err error) bool {
|
|
var failure *RequestFailure
|
|
return errors.As(err, &failure) && failure.Kind == FailureDirectUnauthorized
|
|
}
|