Skip to content

fix: pass Usage, ChatResponseCached, and ToolResults to SDKs #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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