fix(seeder): correct log generation fields

- Parse provider group models from API response string and expose as slice
- Send `model` field (not `model_name`) when creating logs
- Use API key ID as `provider_id` instead of provider group ID
- Restrict reset behavior to resources matching seeder tag/prefix
- Refactor usage sample generation to accept a context struct
This commit is contained in:
zenfun
2026-01-10 00:46:03 +08:00
parent dd32ee817d
commit 5431e24923
3 changed files with 101 additions and 49 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
@@ -182,19 +183,27 @@ type ProviderGroupRequest struct {
GoogleLocation string `json:"google_location,omitempty"`
StaticHeaders string `json:"static_headers,omitempty"`
HeadersProfile string `json:"headers_profile,omitempty"`
Models []string `json:"models,omitempty"`
Models []string `json:"models,omitempty"` // Request uses []string
Status string `json:"status,omitempty"`
}
type ProviderGroupResponse struct {
ID uint `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
BaseURL string `json:"base_url"`
GoogleProject string `json:"google_project"`
GoogleLocation string `json:"google_location"`
Models []string `json:"models"`
Status string `json:"status"`
ID uint `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
BaseURL string `json:"base_url"`
GoogleProject string `json:"google_project"`
GoogleLocation string `json:"google_location"`
Models string `json:"models"` // Response is comma-separated string
Status string `json:"status"`
}
// GetModelsSlice returns the Models field as a slice
func (p *ProviderGroupResponse) GetModelsSlice() []string {
if p.Models == "" {
return nil
}
return strings.Split(p.Models, ",")
}
func (c *Client) ListProviderGroups() ([]ProviderGroupResponse, error) {
@@ -469,7 +478,7 @@ type LogRequest struct {
Group string `json:"group,omitempty"`
MasterID uint `json:"master_id,omitempty"`
KeyID uint `json:"key_id,omitempty"`
ModelName string `json:"model_name,omitempty"`
Model string `json:"model,omitempty"` // Field name is "model" not "model_name"
ProviderID uint `json:"provider_id,omitempty"`
ProviderType string `json:"provider_type,omitempty"`
ProviderName string `json:"provider_name,omitempty"`