| 123456789101112131415161718192021222324252627282930 |
- package service
- import (
- "github.com/gin-gonic/gin"
- "one-api/dto"
- relaycommon "one-api/relay/common"
- )
- func GenerateTextOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, modelRatio, groupRatio, completionRatio, modelPrice float64) map[string]interface{} {
- other := make(map[string]interface{})
- other["model_ratio"] = modelRatio
- other["group_ratio"] = groupRatio
- other["completion_ratio"] = completionRatio
- other["model_price"] = modelPrice
- other["frt"] = float64(relayInfo.FirstResponseTime.UnixMilli() - relayInfo.StartTime.UnixMilli())
- adminInfo := make(map[string]interface{})
- adminInfo["use_channel"] = ctx.GetStringSlice("use_channel")
- other["admin_info"] = adminInfo
- return other
- }
- func GenerateWssOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usage *dto.RealtimeUsage, modelRatio, groupRatio, completionRatio, modelPrice float64) map[string]interface{} {
- info := GenerateTextOtherInfo(ctx, relayInfo, modelRatio, groupRatio, completionRatio, modelPrice)
- info["ws"] = true
- info["audio_input"] = usage.InputTokenDetails.AudioTokens
- info["audio_output"] = usage.OutputTokenDetails.AudioTokens
- info["text_input"] = usage.InputTokenDetails.TextTokens
- info["text_output"] = usage.OutputTokenDetails.TextTokens
- return info
- }
|