mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 18:11:34 +08:00
refactor: update AI result handling to differentiate content and thought based on result types in report generation
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-beta-2506241536
|
||||
v5.0.0-beta-2506241601
|
||||
|
||||
31
report.go
31
report.go
@@ -2442,9 +2442,19 @@ const htmlTemplate = `<!DOCTYPE html>
|
||||
{{if $action.AIResult}}
|
||||
<div class="sub-action-item">
|
||||
<div class="validator-ai-content">
|
||||
<!-- Display AI Thought -->
|
||||
{{if $action.AIResult.Thought}}
|
||||
<div class="thought">{{$action.AIResult.Thought}}</div>
|
||||
<!-- Display AI Thought from specific result types -->
|
||||
{{if eq $action.AIResult.Type "query"}}
|
||||
{{if $action.AIResult.QueryResult.Thought}}
|
||||
<div class="thought">{{$action.AIResult.QueryResult.Thought}}</div>
|
||||
{{end}}
|
||||
{{else if eq $action.AIResult.Type "action"}}
|
||||
{{if $action.AIResult.PlanningResult.Thought}}
|
||||
<div class="thought">{{$action.AIResult.PlanningResult.Thought}}</div>
|
||||
{{end}}
|
||||
{{else if eq $action.AIResult.Type "assert"}}
|
||||
{{if $action.AIResult.AssertionResult.Thought}}
|
||||
<div class="thought">{{$action.AIResult.AssertionResult.Thought}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
<!-- AI Operation Layout: Screenshot left, Analysis right -->
|
||||
@@ -2514,8 +2524,19 @@ const htmlTemplate = `<!DOCTYPE html>
|
||||
{{if $action.AIResult.Resolution}}
|
||||
<div class="model-info">📐 Resolution: {{$action.AIResult.Resolution.Width}}x{{$action.AIResult.Resolution.Height}}</div>
|
||||
{{end}}
|
||||
{{if $action.AIResult.Content}}
|
||||
<div class="model-info">💬 {{title $action.AIResult.Type}} Result: {{$action.AIResult.Content}}</div>
|
||||
{{/* Display Content from specific result types */}}
|
||||
{{if eq $action.AIResult.Type "query"}}
|
||||
{{if $action.AIResult.QueryResult.Content}}
|
||||
<div class="model-info">💬 {{title $action.AIResult.Type}} Result: {{$action.AIResult.QueryResult.Content}}</div>
|
||||
{{end}}
|
||||
{{else if eq $action.AIResult.Type "action"}}
|
||||
{{if $action.AIResult.PlanningResult.Content}}
|
||||
<div class="model-info">💬 {{title $action.AIResult.Type}} Result: {{$action.AIResult.PlanningResult.Content}}</div>
|
||||
{{end}}
|
||||
{{else if eq $action.AIResult.Type "assert"}}
|
||||
{{if $action.AIResult.AssertionResult.Content}}
|
||||
<div class="model-info">💬 {{title $action.AIResult.Type}} Result: {{$action.AIResult.AssertionResult.Content}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -156,8 +156,6 @@ func (dExt *XTDriver) AIAction(ctx context.Context, prompt string, opts ...optio
|
||||
ImagePath: screenResult.ImagePath,
|
||||
Resolution: &screenResult.Resolution,
|
||||
PlanningResult: &planningResult.PlanningResult,
|
||||
Thought: planningResult.Thought,
|
||||
Content: planningResult.Content,
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -341,9 +339,7 @@ type AIExecutionResult struct {
|
||||
AssertionResult *ai.AssertionResult `json:"assertion_result,omitempty"` // for ai_assert operations
|
||||
|
||||
// Common fields
|
||||
Thought string `json:"thought,omitempty"` // AI reasoning/thought process
|
||||
Content string `json:"content,omitempty"` // operation result content
|
||||
Error string `json:"error,omitempty"` // error message if operation failed
|
||||
Error string `json:"error,omitempty"` // error message if operation failed
|
||||
}
|
||||
|
||||
// SubActionResult represents a sub-action within a start_to_goal action
|
||||
@@ -408,8 +404,6 @@ func (dExt *XTDriver) AIQuery(text string, opts ...option.ActionOption) (*AIExec
|
||||
ImagePath: screenResult.ImagePath, // screenshot path
|
||||
Resolution: &screenResult.Resolution, // screen resolution
|
||||
QueryResult: result, // query-specific result
|
||||
Thought: result.Thought, // AI reasoning
|
||||
Content: result.Content, // query result content
|
||||
}
|
||||
return aiResult, nil
|
||||
}
|
||||
@@ -458,7 +452,6 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
|
||||
ImagePath: screenResult.ImagePath,
|
||||
Resolution: &screenResult.Resolution,
|
||||
AssertionResult: result,
|
||||
Thought: result.Thought,
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -471,6 +464,5 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
|
||||
return aiResult, errors.New(result.Thought)
|
||||
}
|
||||
|
||||
aiResult.Content = "Assertion passed"
|
||||
return aiResult, nil
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func (t *ToolAIQuery) Implement() server.ToolHandlerFunc {
|
||||
message := fmt.Sprintf("Successfully queried information with prompt: %s", unifiedReq.Prompt)
|
||||
returnData := ToolAIQuery{
|
||||
Prompt: unifiedReq.Prompt,
|
||||
Result: queryResult.Content,
|
||||
Result: queryResult.QueryResult.Content,
|
||||
}
|
||||
|
||||
return NewMCPSuccessResponse(message, &returnData), nil
|
||||
|
||||
Reference in New Issue
Block a user