Просмотр исходного кода

fix: include cached tokens in tui

adamdottv 8 месяцев назад
Родитель
Сommit
c7bb7ce4de

+ 5 - 1
packages/tui/internal/components/core/status.go

@@ -102,7 +102,11 @@ func (m statusComponent) View() string {
 				cost += message.Metadata.Assistant.Cost
 				usage := message.Metadata.Assistant.Tokens
 				if usage.Output > 0 {
-					tokens = (usage.Input + usage.Output + usage.Reasoning)
+					tokens = (usage.Input +
+						usage.Cache.Write +
+						usage.Cache.Read +
+						usage.Output +
+						usage.Reasoning)
 				}
 			}
 		}

+ 17 - 1
packages/tui/pkg/client/gen/openapi.json

@@ -782,12 +782,28 @@
                       },
                       "reasoning": {
                         "type": "number"
+                      },
+                      "cache": {
+                        "type": "object",
+                        "properties": {
+                          "read": {
+                            "type": "number"
+                          },
+                          "write": {
+                            "type": "number"
+                          }
+                        },
+                        "required": [
+                          "read",
+                          "write"
+                        ]
                       }
                     },
                     "required": [
                       "input",
                       "output",
-                      "reasoning"
+                      "reasoning",
+                      "cache"
                     ]
                   }
                 },

+ 4 - 0
packages/tui/pkg/client/generated-client.go

@@ -126,6 +126,10 @@ type MessageInfo struct {
 			Summary    *bool    `json:"summary,omitempty"`
 			System     []string `json:"system"`
 			Tokens     struct {
+				Cache struct {
+					Read  float32 `json:"read"`
+					Write float32 `json:"write"`
+				} `json:"cache"`
 				Input     float32 `json:"input"`
 				Output    float32 `json:"output"`
 				Reasoning float32 `json:"reasoning"`