mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
feat: enhance VLM response parsing and DOUBAO model support
- Fix JSON extraction logic by prioritizing brace counting method - Add support for DOUBAO string array coordinate format - Introduce IS_UI_TARS helper function for model type checking - Add comprehensive tests for JSON parsing and coordinate handling - Improve error handling with retry delays for LLM service failures
This commit is contained in:
+8
-8
@@ -42,14 +42,7 @@ func extractJSONFromContent(content string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// Case 3: Try regex approach for markdown-like formats
|
||||
jsonRegex := regexp.MustCompile(`(?:json)?\s*({[\s\S]*?})\s*`)
|
||||
matches := jsonRegex.FindStringSubmatch(content)
|
||||
if len(matches) > 1 {
|
||||
return strings.TrimSpace(matches[1])
|
||||
}
|
||||
|
||||
// Case 4: Look for JSON object in the content using brace counting
|
||||
// Case 3: Look for JSON object in the content using brace counting (most reliable method)
|
||||
start := strings.Index(content, "{")
|
||||
if start != -1 {
|
||||
// Find the matching closing brace
|
||||
@@ -67,6 +60,13 @@ func extractJSONFromContent(content string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// Case 4: Try regex approach for markdown-like formats (fallback)
|
||||
jsonRegex := regexp.MustCompile(`(?:json)?\s*({[\s\S]*?})\s*`)
|
||||
matches := jsonRegex.FindStringSubmatch(content)
|
||||
if len(matches) > 1 {
|
||||
return strings.TrimSpace(matches[1])
|
||||
}
|
||||
|
||||
// Case 5: If content itself looks like JSON
|
||||
if strings.HasPrefix(content, "{") && strings.HasSuffix(content, "}") {
|
||||
return content
|
||||
|
||||
Reference in New Issue
Block a user