Skip to content

Commit

Permalink
fix: pass Usage, ChatResponseCached, and ToolResults to SDKs (#860)
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <donnie@acorn.io>
  • Loading branch information
thedadams authored Sep 25, 2024
1 parent ec0c019 commit f922de1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pkg/sdkserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func (r *runInfo) process(e event) map[string]any {
if e.Content != "" {
call.Input = e.Content
}
if e.ToolResults > 0 {
call.ToolResults = e.ToolResults
}

case runner.EventTypeCallSubCalls:
call.setSubCalls(e.ToolSubCalls)
Expand All @@ -185,6 +188,8 @@ func (r *runInfo) process(e event) map[string]any {
call.setOutput(e.Content)

case runner.EventTypeChat:
call.Usage = e.Usage
call.ChatResponseCached = e.ChatResponseCached
if e.ChatRequest != nil {
call.LLMRequest = e.ChatRequest
}
Expand All @@ -210,14 +215,16 @@ func (r *runInfo) processStdout(cs runner.ChatResponse) {
type call struct {
engine.CallContext `json:",inline"`

Type runner.EventType `json:"type"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Input string `json:"input"`
Output []output `json:"output"`
Usage types.Usage `json:"usage"`
LLMRequest any `json:"llmRequest"`
LLMResponse any `json:"llmResponse"`
Type runner.EventType `json:"type"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Input string `json:"input"`
Output []output `json:"output"`
Usage types.Usage `json:"usage"`
ChatResponseCached bool `json:"chatResponseCached"`
ToolResults int `json:"toolResults"`
LLMRequest any `json:"llmRequest"`
LLMResponse any `json:"llmResponse"`
}

func (c *call) setSubCalls(subCalls map[string]engine.Call) {
Expand Down

0 comments on commit f922de1

Please sign in to comment.