(channel *model.Channel)
| 170 | } |
| 171 | |
| 172 | func updateChannelOpenAISBBalance(channel *model.Channel) (float64, error) { |
| 173 | url := fmt.Sprintf("https://api.openai-sb.com/sb-api/user/status?api_key=%s", channel.Key) |
| 174 | body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key)) |
| 175 | if err != nil { |
| 176 | return 0, err |
| 177 | } |
| 178 | response := OpenAISBUsageResponse{} |
| 179 | err = json.Unmarshal(body, &response) |
| 180 | if err != nil { |
| 181 | return 0, err |
| 182 | } |
| 183 | if response.Data == nil { |
| 184 | return 0, errors.New(response.Msg) |
| 185 | } |
| 186 | balance, err := strconv.ParseFloat(response.Data.Credit, 64) |
| 187 | if err != nil { |
| 188 | return 0, err |
| 189 | } |
| 190 | channel.UpdateBalance(balance) |
| 191 | return balance, nil |
| 192 | } |
| 193 | |
| 194 | func updateChannelAIProxyBalance(channel *model.Channel) (float64, error) { |
| 195 | url := "https://aiproxy.io/api/report/getUserOverview" |
nothing calls this directly
no test coverage detected