|
1 | 1 | package inference |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "strconv" |
5 | 6 |
|
6 | 7 | "github.com/vultr/govultr/v3" |
@@ -126,10 +127,67 @@ func (u *UsagePrinter) Columns() [][]string { |
126 | 127 | // Data ... |
127 | 128 | func (u *UsagePrinter) Data() [][]string { |
128 | 129 | var data [][]string |
| 130 | + |
| 131 | + data = append(data, |
| 132 | + []string{"---------------------------"}, |
| 133 | + []string{"CHAT USAGE (CURRENT MONTH)"}, |
| 134 | + []string{"---------------------------"}, |
| 135 | + ) |
| 136 | + |
| 137 | + if len(u.Usage.ChatByModel.CurrentMonth) == 0 { |
| 138 | + data = append(data, |
| 139 | + []string{"None"}, |
| 140 | + []string{" "}, |
| 141 | + ) |
| 142 | + } else { |
| 143 | + for i := range u.Usage.ChatByModel.CurrentMonth { |
| 144 | + data = append(data, |
| 145 | + []string{"MODEL", u.Usage.ChatByModel.CurrentMonth[i].Model}, |
| 146 | + []string{"TOKENS", strconv.Itoa(u.Usage.ChatByModel.CurrentMonth[i].Tokens)}, |
| 147 | + []string{"INPUT TOKENS", strconv.Itoa(u.Usage.ChatByModel.CurrentMonth[i].InputTokens)}, |
| 148 | + []string{"OUTPUT PRICE", strconv.Itoa(u.Usage.ChatByModel.CurrentMonth[i].OutputPrice)}, |
| 149 | + []string{"INPUT PRICE", strconv.Itoa(u.Usage.ChatByModel.CurrentMonth[i].InputPrice)}, |
| 150 | + []string{" "}, |
| 151 | + ) |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + data = append(data, |
| 156 | + []string{"---------------------------"}, |
| 157 | + []string{"CHAT USAGE (PREVIOUS MONTH)"}, |
| 158 | + []string{"---------------------------"}, |
| 159 | + ) |
| 160 | + |
| 161 | + if len(u.Usage.ChatByModel.PreviousMonth) == 0 { |
| 162 | + data = append(data, |
| 163 | + []string{"None"}, |
| 164 | + []string{" "}, |
| 165 | + ) |
| 166 | + } else { |
| 167 | + for i := range u.Usage.ChatByModel.PreviousMonth { |
| 168 | + data = append(data, |
| 169 | + []string{"MODEL", u.Usage.ChatByModel.PreviousMonth[i].Model}, |
| 170 | + []string{"TOKENS", strconv.Itoa(u.Usage.ChatByModel.PreviousMonth[i].Tokens)}, |
| 171 | + []string{"INPUT TOKENS", strconv.Itoa(u.Usage.ChatByModel.PreviousMonth[i].InputTokens)}, |
| 172 | + []string{"OUTPUT PRICE", strconv.Itoa(u.Usage.ChatByModel.PreviousMonth[i].OutputPrice)}, |
| 173 | + []string{"INPUT PRICE", strconv.Itoa(u.Usage.ChatByModel.PreviousMonth[i].InputPrice)}, |
| 174 | + []string{" "}, |
| 175 | + ) |
| 176 | + } |
| 177 | + } |
| 178 | + |
129 | 179 | data = append(data, |
| 180 | + []string{"---------------------------"}, |
130 | 181 | []string{"AUDIO USAGE"}, |
131 | | - []string{"TTS CHARACTERS", strconv.FormatInt(int64(u.Usage.Audio.TTSCharacters), 10)}, |
132 | | - []string{"TTS (SM) CHARACTERS", strconv.FormatInt(int64(u.Usage.Audio.TTSSMCharacters), 10)}, |
| 182 | + []string{"---------------------------"}, |
| 183 | + []string{"TTS CHARACTERS", strconv.Itoa(u.Usage.Audio.TTSCharacters)}, |
| 184 | + []string{"TTS (SM) CHARACTERS", strconv.Itoa(u.Usage.Audio.TTSSMCharacters)}, |
| 185 | + []string{" "}, |
| 186 | + []string{"---------------------------"}, |
| 187 | + []string{"IMAGE USAGE"}, |
| 188 | + []string{"---------------------------"}, |
| 189 | + []string{"MEGAPIXELS", fmt.Sprintf("%g", u.Usage.Image.Megapixels)}, |
| 190 | + []string{"MEGAPIXELS (SM)", fmt.Sprintf("%g", u.Usage.Image.SMMegapixels)}, |
133 | 191 | ) |
134 | 192 |
|
135 | 193 | return data |
|
0 commit comments