mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-13 00:11:28 +08:00
fix: resolve doubao-seed-1.6-250615 model API 400 error with empty content
- Fix Tool message content issue when model returns empty content in function calling - Add content validation in callModelWithLogging to handle empty content in messages - Ensure compatibility between UI-TARS and function calling models This resolves the "missing messages.content parameter" error when using doubao-seed-1.6-250615 model compared to doubao-1.5-ui-tars-250328
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2506252017
|
v5.0.0-beta-2506261057
|
||||||
|
|||||||
@@ -135,9 +135,17 @@ func (p *Planner) Plan(ctx context.Context, opts *PlanningOptions) (result *Plan
|
|||||||
for _, toolCall := range message.ToolCalls {
|
for _, toolCall := range message.ToolCalls {
|
||||||
toolCallID += toolCall.ID
|
toolCallID += toolCall.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure content is not empty for Tool messages to avoid API 400 errors
|
||||||
|
// Some models may return empty content when using function calling
|
||||||
|
toolContent := message.Content
|
||||||
|
if toolContent == "" {
|
||||||
|
toolContent = "Function call initiated"
|
||||||
|
}
|
||||||
|
|
||||||
p.history.Append(&schema.Message{
|
p.history.Append(&schema.Message{
|
||||||
Role: schema.Tool,
|
Role: schema.Tool,
|
||||||
Content: message.Content,
|
Content: toolContent,
|
||||||
ToolCalls: message.ToolCalls,
|
ToolCalls: message.ToolCalls,
|
||||||
ToolCallID: toolCallID,
|
ToolCallID: toolCallID,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -456,7 +456,30 @@ func extractPlanningFieldsManually(content string) (*PlanningJSONResponse, error
|
|||||||
// 4. Log timing and model info
|
// 4. Log timing and model info
|
||||||
// 5. Log response
|
// 5. Log response
|
||||||
func callModelWithLogging(ctx context.Context, model model.ToolCallingChatModel, history ConversationHistory, modelType option.LLMServiceType, operation string) (*schema.Message, error) {
|
func callModelWithLogging(ctx context.Context, model model.ToolCallingChatModel, history ConversationHistory, modelType option.LLMServiceType, operation string) (*schema.Message, error) {
|
||||||
logRequest(history)
|
// Clean up messages before sending to avoid API 400 errors
|
||||||
|
// Some models require that messages with MultiContent should not have empty content
|
||||||
|
cleanedHistory := make(ConversationHistory, 0, len(history))
|
||||||
|
for _, message := range history {
|
||||||
|
cleanedMsg := &schema.Message{
|
||||||
|
Role: message.Role,
|
||||||
|
Content: message.Content,
|
||||||
|
MultiContent: message.MultiContent,
|
||||||
|
ToolCalls: message.ToolCalls,
|
||||||
|
ToolCallID: message.ToolCallID,
|
||||||
|
Extra: message.Extra,
|
||||||
|
}
|
||||||
|
|
||||||
|
// For user messages with MultiContent, ensure content is not empty string
|
||||||
|
// to avoid "missing messages.content parameter" error
|
||||||
|
if message.Role == schema.User && len(message.MultiContent) > 0 && message.Content == "" {
|
||||||
|
// Don't set content field for messages with MultiContent
|
||||||
|
cleanedMsg.Content = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanedHistory = append(cleanedHistory, cleanedMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
logRequest(cleanedHistory)
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -465,7 +488,7 @@ func callModelWithLogging(ctx context.Context, model model.ToolCallingChatModel,
|
|||||||
Msgf("call model service for %s", operation)
|
Msgf("call model service for %s", operation)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
message, err := model.Generate(ctx, history)
|
message, err := model.Generate(ctx, cleanedHistory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user