PURE_GUI_FUNCTIONS = """{"name": "click", "description": "Mouse left single click action.", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}}
{"name": "drag", "description": "Mouse left button drag action.", "parameters": {"type": "object", "properties": {"start_point": {"type": "string", "description": "Drag start point. The format is: <point>x y</point>"}, "end_point": {"type": "string", "description": "Drag end point. The format is: <point>x y</point>"}}, "required": ["start_point", "end_point"]}}
{"name": "hotkey", "description": "Press hotkey.", "parameters": {"type": "object", "properties": {"key": {"type": "string", "description": "Hotkeys you want to press. Split keys with a space and use lowercase."}}, "required": ["key"]}}
{"name": "left_double", "description": "Mouse left double click action.", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}}
{"name": "right_single", "description": "Mouse right single click action.", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}}
{"name": "scroll", "description": "Scroll action.", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Scroll start position. If not specified, default to execute on the current mouse position. The format is: <point>x y</point>"}, "direction": {"type": "string", "description": "Scroll direction.", "enum": ["up", "down", "left", "right"]}}, "required": ["direction", "point"]}}
{"name": "type", "description": "Type content.", "parameters": {"type": "object", "properties": {"content": {"type": "string", "description": "Type content. If you want to submit your input, use \\n at the end of content."}}, "required": ["content"]}}
{"name": "wait", "description": "Wait for a while.", "parameters": {"type": "object", "properties": {"time": {"type": "integer", "description": "Wait time in seconds."}}, "required": []}}"""
PURE_GUI_SCHEMAS = functions_block_to_schemas(PURE_GUI_FUNCTIONS)
THINK_TOKEN = "think_never_used_51bce0c785ca2f68081bfa7d91973934"
TASK_SP = """You are provided with a task description, a history of previous actions, and corresponding screenshots. Your goal is to perform the next action to complete the task. Please note that if performing the same action multiple times results in a static screen with no changes, you should attempt a modified or alternative action."""
FUNCTION_SP = f"""## Function Definition
- You have access to the following functions:
- To call a function, use the following structure without any suffix:
<{THINK_TOKEN}> reasoning process </{THINK_TOKEN}>
<seed:tool_call><function name="example_function_name"><parameter name="example_parameter_1" string="false|true">value_1</parameter></function></seed:tool_call>
- All required parameters must be explicitly provided.
- The string attribute within the parameter tag specifies the type of the parameter value. For instance, if the value is an integer, number, or boolean, set string="false". If the value is a string, set string="true". Example:
<parameter name="parameter1" string="false">1</parameter>
<parameter name="parameter1" string="false">1.0</parameter>
<parameter name="parameter2" string="false">true</parameter>
<parameter name="parameter3" string="true">This is a test 1.</parameter>
- For complex parameter types, such as lists or objects, set string="false" and provide the parameter value in JSON format. Example:
<parameter name="parameter4" string="false">{{"key1": "value1", "key2": "value2"}}</parameter>
<parameter name="parameter5" string="false">[1, 2, 3]</parameter>"""
def build_system_prompt() -> list[dict]:
"""纯 GUI 主线的两段式 system prompt(任务框架 + 动作定义)。"""
{"role": "system", "content": TASK_SP},
{"role": "system", "content": FUNCTION_SP},
def build_user_message(task: str, data_url: str) -> dict:
"""构造一条多模态 user 消息:文本任务 + 一张截图。"""
{"type": "text", "text": task},
{"type": "image_url", "image_url": {"url": data_url}},
messages = build_system_prompt() + [build_user_message(task, data_url)]