66 "fmt"
77 "io"
88 "os"
9- "sort "
9+ "slices "
1010 "strings"
1111 "sync/atomic"
1212 "time"
@@ -87,18 +87,18 @@ func (d *display) Event(event runner.Event) {
8787 case runner .EventTypeCallStart :
8888 currentCall .Start = event .Time
8989 currentCall .Input = event .Content
90- log .Fields ("input" , event .Content ).Infof ("%s started " , callName )
90+ log .Fields ("input" , event .Content ).Infof ("started [%s] " , callName )
9191 case runner .EventTypeCallProgress :
9292 case runner .EventTypeCallContinue :
93- log .Fields ("toolResults" , event .ToolResults ).Infof ("%s continue " , callName )
93+ log .Fields ("toolResults" , event .ToolResults ).Infof ("continue [%s] " , callName )
9494 case runner .EventTypeChat :
9595 if event .ChatRequest == nil {
9696 log = log .Fields (
9797 "response" , toJSON (event .ChatResponse ),
9898 "cached" , event .ChatResponseCached ,
9999 )
100100 } else {
101- log .Infof ("%s openai request sent" , callName )
101+ log .Infof ("openai request sent [%s] " , callName )
102102 log = log .Fields (
103103 "request" , toJSON (event .ChatRequest ),
104104 )
@@ -112,7 +112,7 @@ func (d *display) Event(event runner.Event) {
112112 case runner .EventTypeCallFinish :
113113 currentCall .End = event .Time
114114 currentCall .Output = event .Content
115- log .Fields ("output" , event .Content ).Infof ("%s ended " , callName )
115+ log .Fields ("output" , event .Content ).Infof ("ended [%s] " , callName )
116116 }
117117
118118 d .dump .Calls [currentIndex ] = currentCall
@@ -158,6 +158,10 @@ type jsonDump struct {
158158 obj any
159159}
160160
161+ func (j jsonDump ) MarshalJSON () ([]byte , error ) {
162+ return json .Marshal (j .obj )
163+ }
164+
161165func (j jsonDump ) String () string {
162166 d , err := json .Marshal (j .obj )
163167 if err != nil {
@@ -184,6 +188,9 @@ func (c callName) String() string {
184188 if name == "" {
185189 name = tool .Source .File
186190 }
191+ if currentCall .ID != "1" {
192+ name += "(" + currentCall .ID + ")"
193+ }
187194 msg = append (msg , name )
188195 found := false
189196 for _ , parent := range c .calls {
@@ -198,7 +205,7 @@ func (c callName) String() string {
198205 }
199206 }
200207
201- sort . Sort ( sort . Reverse (sort . StringSlice ( msg )) )
208+ slices . Reverse (msg )
202209 return strings .Join (msg , "->" )
203210}
204211
@@ -227,3 +234,7 @@ type call struct {
227234 Input string `json:"input,omitempty"`
228235 Output string `json:"output,omitempty"`
229236}
237+
238+ func (c call ) String () string {
239+ return c .ID
240+ }
0 commit comments