Improve the transcript: tool grouping, report auto-ack, context meter, spinner, Enter to send
This commit is contained in:
@@ -58,12 +58,45 @@ type Block struct {
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
Subtype string `json:"subtype"`
|
||||
IsError bool `json:"is_error"`
|
||||
Result string `json:"result"`
|
||||
DurationMS int `json:"duration_ms"`
|
||||
NumTurns int `json:"num_turns"`
|
||||
TotalCostUSD float64 `json:"total_cost_usd"`
|
||||
Subtype string `json:"subtype"`
|
||||
IsError bool `json:"is_error"`
|
||||
Result string `json:"result"`
|
||||
DurationMS int `json:"duration_ms"`
|
||||
NumTurns int `json:"num_turns"`
|
||||
TotalCostUSD float64 `json:"total_cost_usd"`
|
||||
ModelUsage map[string]ModelUsage `json:"modelUsage"`
|
||||
}
|
||||
|
||||
type ModelUsage struct {
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
}
|
||||
|
||||
type ContextUsage struct {
|
||||
Model string
|
||||
Tokens int
|
||||
}
|
||||
|
||||
func (e Event) ContextUsage() (ContextUsage, error) {
|
||||
msg := struct {
|
||||
Message struct {
|
||||
Model string `json:"model"`
|
||||
Usage struct {
|
||||
InputTokens int `json:"input_tokens"`
|
||||
CacheCreationInputTokens int `json:"cache_creation_input_tokens"`
|
||||
CacheReadInputTokens int `json:"cache_read_input_tokens"`
|
||||
OutputTokens int `json:"output_tokens"`
|
||||
} `json:"usage"`
|
||||
} `json:"message"`
|
||||
}{}
|
||||
err := json.Unmarshal(e.Raw, &msg)
|
||||
if err != nil {
|
||||
return ContextUsage{}, err
|
||||
}
|
||||
u := msg.Message.Usage
|
||||
return ContextUsage{
|
||||
Model: msg.Message.Model,
|
||||
Tokens: u.InputTokens + u.CacheCreationInputTokens + u.CacheReadInputTokens + u.OutputTokens,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e Event) Blocks() ([]Block, error) {
|
||||
|
||||
Reference in New Issue
Block a user