change: append tool call message for planner

This commit is contained in:
lilong.129
2025-05-24 10:28:55 +08:00
parent b639b4473f
commit 014140ccc7
3 changed files with 15 additions and 2 deletions

View File

@@ -1 +1 @@
v5.0.0-beta-2505240100
v5.0.0-beta-2505241028

View File

@@ -370,7 +370,7 @@ func convertActionsToToolCalls(actions []Action) []schema.ToolCall {
ID: action.ActionType + "_" + strconv.FormatInt(time.Now().Unix(), 10),
Type: "function",
Function: schema.FunctionCall{
Name: action.ActionType,
Name: "uixt__" + action.ActionType,
Arguments: string(jsonArgs),
},
})

View File

@@ -112,6 +112,12 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
// handle tool calls
if len(message.ToolCalls) > 0 {
// append tool call message
p.history.Append(&schema.Message{
Role: schema.Tool,
Content: message.Content,
ToolCalls: message.ToolCalls,
})
// history will be appended with tool calls execution result
result := &PlanningResult{
ToolCalls: message.ToolCalls,
@@ -133,6 +139,13 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
Role: schema.Assistant,
Content: message.Content,
})
} else {
// append tool call message
p.history.Append(&schema.Message{
Role: schema.Tool,
Content: result.Content,
ToolCalls: result.ToolCalls,
})
}
log.Info().