mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-06 15:01:22 +08:00
fix: miss tool call ID
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2505260905
|
v5.0.0-beta-2505260928
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package ai
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||||
@@ -113,10 +114,15 @@ 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
|
// append tool call message
|
||||||
|
toolCallID := ""
|
||||||
|
for _, toolCall := range message.ToolCalls {
|
||||||
|
toolCallID += toolCall.ID
|
||||||
|
}
|
||||||
p.history.Append(&schema.Message{
|
p.history.Append(&schema.Message{
|
||||||
Role: schema.Tool,
|
Role: schema.Tool,
|
||||||
Content: message.Content,
|
Content: message.Content,
|
||||||
ToolCalls: message.ToolCalls,
|
ToolCalls: message.ToolCalls,
|
||||||
|
ToolCallID: toolCallID,
|
||||||
})
|
})
|
||||||
// history will be appended with tool calls execution result
|
// history will be appended with tool calls execution result
|
||||||
result := &PlanningResult{
|
result := &PlanningResult{
|
||||||
@@ -140,11 +146,12 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
|
|||||||
Content: message.Content,
|
Content: message.Content,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// append tool call message
|
// append assistant message with tool calls
|
||||||
p.history.Append(&schema.Message{
|
p.history.Append(&schema.Message{
|
||||||
Role: schema.Tool,
|
Role: schema.Tool,
|
||||||
Content: result.Content,
|
Content: result.Content,
|
||||||
ToolCalls: result.ToolCalls,
|
ToolCalls: result.ToolCalls,
|
||||||
|
ToolCallID: fmt.Sprintf("%d", time.Now().Unix()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func logRequest(messages ConversationHistory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func logResponse(message *schema.Message) {
|
func logResponse(message *schema.Message) {
|
||||||
logger := log.Info().Str("role", string(message.Role)).
|
logger := log.Debug().Str("role", string(message.Role)).
|
||||||
Str("content", message.Content)
|
Str("content", message.Content)
|
||||||
|
|
||||||
var toolCalls []string
|
var toolCalls []string
|
||||||
|
|||||||
Reference in New Issue
Block a user