mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-08 07:03:40 +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),
|
ID: action.ActionType + "_" + strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
Type: "function",
|
Type: "function",
|
||||||
Function: schema.FunctionCall{
|
Function: schema.FunctionCall{
|
||||||
Name: action.ActionType,
|
Name: "uixt__" + action.ActionType,
|
||||||
Arguments: string(jsonArgs),
|
Arguments: string(jsonArgs),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
|
|||||||
|
|
||||||
// handle tool calls
|
// handle tool calls
|
||||||
if len(message.ToolCalls) > 0 {
|
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
|
// history will be appended with tool calls execution result
|
||||||
result := &PlanningResult{
|
result := &PlanningResult{
|
||||||
ToolCalls: message.ToolCalls,
|
ToolCalls: message.ToolCalls,
|
||||||
@@ -133,6 +139,13 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
|
|||||||
Role: schema.Assistant,
|
Role: schema.Assistant,
|
||||||
Content: message.Content,
|
Content: message.Content,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// append tool call message
|
||||||
|
p.history.Append(&schema.Message{
|
||||||
|
Role: schema.Tool,
|
||||||
|
Content: result.Content,
|
||||||
|
ToolCalls: result.ToolCalls,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
|
|||||||
Reference in New Issue
Block a user