fix(seeder): improve key idempotency and log names

Trim whitespace in provider model lists, format provider names as `group#keyID`
to match DP logs, and skip existing API keys during seeding (deleting on reset)
to keep runs idempotent and summaries accurate
This commit is contained in:
zenfun
2026-01-10 00:58:02 +08:00
parent 5431e24923
commit 6af938448e
3 changed files with 121 additions and 9 deletions

View File

@@ -407,14 +407,20 @@ func (g *Generator) GenerateUsageSamples(ctx UsageSampleContext) []LogRequest {
// For historical data, we would need direct DB access.
// Current implementation creates logs at "now" time.
// Format provider_name as group#keyID to match DP log format
providerName := group.Name
if providerID > 0 {
providerName = fmt.Sprintf("%s#%d", group.Name, providerID)
}
result = append(result, LogRequest{
Group: master.Group,
MasterID: master.ID,
KeyID: keyID,
Model: modelName, // Fixed: use Model not ModelName
ProviderID: providerID, // Fixed: use APIKey ID not group ID
Model: modelName,
ProviderID: providerID,
ProviderType: group.Type,
ProviderName: group.Name,
ProviderName: providerName,
StatusCode: statusCode,
LatencyMs: latencyMs,
TokensIn: tokensIn,