feat: sync deployed v1.0.0-rc.38-custom.67

This commit is contained in:
cneicy committed 2026-10-06 00:07:10 +08:00
1 parent d09216bbde
commit 8e6ed0317b
154 files changed
+39540 -20509

No files matched your search

+17 -3
View File
@@ -11,7 +11,7 @@ import (
fingerprint "github.com/QuantumNous/new-api/pkg/model_fingerprint"
)
const AstraSamplingTaskType = "astra_fingerprint"
const AstraSamplingTaskType = "modeltrace_sampling"
const (
AstraSamplingWindow = 6 * time.Hour
@@ -55,6 +55,7 @@ type AstraSamplingHistory struct {
Gap float64 `json:"score_gap,omitempty"`
}
type AstraSamplingSummary struct {
LatestValid *AstraSamplingHistory `json:"-"`
Enabled bool `json:"enabled"`
Available bool `json:"available"`
Channels int `json:"channels"`
@@ -123,6 +124,9 @@ func AstraAvailabilityIntervalMinutes() int {
// Public statistics classify completed rounds by their closest valid fingerprint,
// including partial rounds. Raw probe results retain the scorer's confidence.
func AstraSamplingResultStatus(result fingerprint.Result) string {
if result.Engine != "" {
return result.Status
}
closest := strings.TrimSpace(result.Closest)
if result.Status != "running" && result.ValidSamples > 0 && closest != "" {
if strings.EqualFold(closest, fingerprint.Model) {
@@ -162,7 +166,7 @@ func samplingChannels(ctx context.Context, requireAstra bool) ([]model.Channel,
}
func AstraSamplingChannelsDue(ctx context.Context, now time.Time) ([]model.Channel, error) {
due, _, err := AutomaticDetectionChannelsDue(ctx, "fingerprint", now)
due, _, err := AutomaticDetectionChannelsDue(ctx, "modeltrace", now)
return due, err
}
@@ -183,7 +187,7 @@ func AstraSamplingSummaries(ctx context.Context, now time.Time, settings map[str
}
summaries := aggregateAstraSampling(channels, tasks, now, settings)
AggregateChannelAvailability(summaries, channels, availabilityTasks, now)
ranges, err := DetectionScheduleRanges(ctx, channels, "fingerprint")
ranges, err := DetectionScheduleRanges(ctx, channels, "modeltrace")
if err != nil {
return nil, err
}
@@ -224,6 +228,9 @@ func aggregateAstraSampling(channels []model.Channel, tasks []*model.SystemTask,
continue
}
for _, round := range state.Rounds {
if round.Result.Engine != fingerprint.Version && round.Result.Status != "running" {
continue
}
if round.StartedAt < now.Add(-AstraSamplingWindow).Unix() {
continue
}
@@ -272,6 +279,13 @@ func aggregateAstraSampling(channels []model.Channel, tasks []*model.SystemTask,
s.Rate = &rate
}
sort.SliceStable(s.History, func(i, j int) bool { return s.History[i].At > s.History[j].At })
for i := range s.History {
round := &s.History[i]
if round.ValidSamples > 0 && round.Closest != "" && (round.Status == "match" || round.Status == "mismatch") {
s.LatestValid = round
break
}
}
if len(s.History) > 12 {
s.History = s.History[:12]
}