mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 06:12:43 +08:00
change: append tool call message for planner
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-beta-2505240100
|
||||
v5.0.0-beta-2505241028
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user