mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 08:57:57 +00:00
fix(gateway): record actual served model for image requests
handleImage recorded the raw request model id, so AUTO image generations showed up as model=AUTO in the request records and by-model aggregates instead of the image model actually served (e.g. Kwai-Kolors/Kolors). UnifiedResponse gains an optional Model field; Provider.Image fills it with the resolved id (AUTO resolves to the source's best image model), and handleImage prefers it when writing the audit record.
This commit is contained in:
@ -988,6 +988,7 @@ func (p *Provider) Image(ctx context.Context, req *types.ImageGenRequest) (*type
|
||||
unified, terr := p.vm.Transform(p.adapter+"_image", "transform_response", raw)
|
||||
if terr == nil && unified != raw {
|
||||
if err := json.Unmarshal([]byte(unified), &out); err == nil {
|
||||
out.Model = model // actual model served (AUTO resolved to bestImageModel)
|
||||
p.RecordSuccess(model)
|
||||
return &out, nil
|
||||
}
|
||||
@ -1000,6 +1001,7 @@ func (p *Provider) Image(ctx context.Context, req *types.ImageGenRequest) (*type
|
||||
return nil, fmt.Errorf("unmarshal image response: %w", err)
|
||||
}
|
||||
out.ImageData = img.Data
|
||||
out.Model = model // actual model served (AUTO resolved to bestImageModel)
|
||||
p.RecordSuccess(model)
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user