refactor: rename to AssertionResult

This commit is contained in:
lilong.129
2025-05-19 11:51:49 +08:00
parent 3f1ee03529
commit b2ab14efcc
3 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
v5.0.0-beta-2505182155 v5.0.0-beta-2505191151
+2 -2
View File
@@ -16,7 +16,7 @@ import (
// ILLMService 定义了 LLM 服务接口,包括规划和断言功能 // ILLMService 定义了 LLM 服务接口,包括规划和断言功能
type ILLMService interface { type ILLMService interface {
Call(ctx context.Context, opts *PlanningOptions) (*PlanningResult, error) Call(ctx context.Context, opts *PlanningOptions) (*PlanningResult, error)
Assert(ctx context.Context, opts *AssertOptions) (*AssertionResponse, error) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResult, error)
} }
func NewLLMService(modelType option.LLMServiceType) (ILLMService, error) { func NewLLMService(modelType option.LLMServiceType) (ILLMService, error) {
@@ -53,7 +53,7 @@ func (c *combinedLLMService) Call(ctx context.Context, opts *PlanningOptions) (*
} }
// Assert 执行断言功能 // Assert 执行断言功能
func (c *combinedLLMService) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResponse, error) { func (c *combinedLLMService) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResult, error) {
return c.asserter.Assert(ctx, opts) return c.asserter.Assert(ctx, opts)
} }
+6 -6
View File
@@ -22,7 +22,7 @@ import (
// IAsserter interface defines the contract for assertion operations // IAsserter interface defines the contract for assertion operations
type IAsserter interface { type IAsserter interface {
Assert(ctx context.Context, opts *AssertOptions) (*AssertionResponse, error) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResult, error)
} }
// AssertOptions represents the input options for assertion // AssertOptions represents the input options for assertion
@@ -32,8 +32,8 @@ type AssertOptions struct {
Size types.Size `json:"size"` // Screen dimensions Size types.Size `json:"size"` // Screen dimensions
} }
// AssertionResponse represents the response from an AI assertion // AssertionResult represents the response from an AI assertion
type AssertionResponse struct { type AssertionResult struct {
Pass bool `json:"pass"` Pass bool `json:"pass"`
Thought string `json:"thought"` Thought string `json:"thought"`
} }
@@ -91,7 +91,7 @@ func NewAsserter(ctx context.Context, modelConfig *ModelConfig) (*Asserter, erro
} }
// Assert performs the assertion check on the screenshot // Assert performs the assertion check on the screenshot
func (a *Asserter) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResponse, error) { func (a *Asserter) Assert(ctx context.Context, opts *AssertOptions) (*AssertionResult, error) {
// Validate input parameters // Validate input parameters
if err := validateAssertionInput(opts); err != nil { if err := validateAssertionInput(opts); err != nil {
return nil, errors.Wrap(err, "validate assertion parameters failed") return nil, errors.Wrap(err, "validate assertion parameters failed")
@@ -169,7 +169,7 @@ func validateAssertionInput(opts *AssertOptions) error {
} }
// parseAssertionResult parses the model response into AssertionResponse // parseAssertionResult parses the model response into AssertionResponse
func parseAssertionResult(content string) (*AssertionResponse, error) { func parseAssertionResult(content string) (*AssertionResult, error) {
// Extract JSON content from response // Extract JSON content from response
jsonContent := extractJSON(content) jsonContent := extractJSON(content)
if jsonContent == "" { if jsonContent == "" {
@@ -177,7 +177,7 @@ func parseAssertionResult(content string) (*AssertionResponse, error) {
} }
// Parse JSON response // Parse JSON response
var result AssertionResponse var result AssertionResult
if err := json.Unmarshal([]byte(jsonContent), &result); err != nil { if err := json.Unmarshal([]byte(jsonContent), &result); err != nil {
return nil, errors.Wrap(code.LLMParseAssertionResponseError, err.Error()) return nil, errors.Wrap(code.LLMParseAssertionResponseError, err.Error())
} }