mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 08:27:35 +08:00
feat: add AI Querier module with custom output schema support and refactor common model calling logic
- Add new AI Querier module for structured information extraction from screenshots - Support custom output schema for structured data response - Implement automatic type conversion and data validation - Add comprehensive test suite with various data structure examples - Refactor callModelWithLogging to utils.go as shared function for planner, asserter, and querier - Eliminate code duplication across AI modules (30+ lines of repeated code) - Improve maintainability with unified logging and timing logic - Add environment variable checks in test setup to handle missing API keys gracefully Key features: - Custom output schema support with JSON Schema generation - Automatic data type conversion with reflection - Fallback mechanisms for robust parsing - Comprehensive documentation and usage examples - Backward compatibility with existing functionality
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package ai
|
||||
|
||||
// Default query system prompt
|
||||
const defaultQueryPrompt = `You are an AI assistant specialized in analyzing images and extracting information. User will provide a screenshot and a query asking for specific information to be extracted from the image. Please analyze the image carefully and provide the requested information.`
|
||||
|
||||
// UI-TARS query response format
|
||||
const uiTarsQueryResponseFormat = `
|
||||
## Output Json String Format
|
||||
` + "```" + `
|
||||
"{
|
||||
"content": "<<is a string containing the extracted information or analysis result>>",
|
||||
"thought": "<<is a string explaining your analysis process and reasoning. Use Chinese.>>"
|
||||
}"
|
||||
` + "```" + `
|
||||
|
||||
## Rules **MUST** follow
|
||||
- Make sure to return **only** the JSON, with **no additional** text or explanations.
|
||||
- Use Chinese in ` + "`Thought`" + ` part.
|
||||
- You **MUST** strictly follow up the **Output Json String Format**.
|
||||
- Provide detailed and accurate information extraction based on the image content.`
|
||||
Reference in New Issue
Block a user