We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 415de95 commit 94331b4Copy full SHA for 94331b4
run.go
@@ -118,6 +118,21 @@ func (r *Run) ParentCallFrame() (CallFrame, bool) {
118
return r.calls.ParentCallFrame(), true
119
}
120
121
+// Usage returns all the usage for this run.
122
+func (r *Run) Usage() Usage {
123
+ var u Usage
124
+ r.callsLock.RLock()
125
+ defer r.callsLock.RUnlock()
126
+
127
+ for _, c := range r.calls {
128
+ u.CompletionTokens += c.Usage.CompletionTokens
129
+ u.PromptTokens += c.Usage.PromptTokens
130
+ u.TotalTokens += c.Usage.TotalTokens
131
+ }
132
133
+ return u
134
+}
135
136
// ErrorOutput returns the stderr output of the gptscript.
137
// Should only be called after Bytes or Text has returned an error.
138
func (r *Run) ErrorOutput() string {
0 commit comments