Enhance logging and error handling in processing logic

- Enhance logging by including requested image counts for improved tracking.
- Implement user quota validation before processing image requests.
- Improve error handling for model validation and JSON unmarshalling in billing processes.
This commit is contained in:
Laisky.Cai
2025-03-16 07:47:59 +00:00
parent fa794e7bd5
commit 400ee3aa24
2 changed files with 52 additions and 3 deletions

View File

@@ -226,7 +226,8 @@ func RelayImageHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
}
if quota >= 0 {
tokenName := c.GetString(ctxkey.TokenName)
logContent := fmt.Sprintf("model rate %.2f, group rate %.2f", modelRatio, groupRatio)
logContent := fmt.Sprintf("model rate %.2f, group rate %.2f, num %d",
modelRatio, groupRatio, imageRequest.N)
model.RecordConsumeLog(ctx, &model.Log{
UserId: meta.UserId,
ChannelId: meta.ChannelId,