This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
PLANNER_SYSTEM_PROMPT = """You are the planning brain of a mobile device automation agent.
|
||||
@@ -66,8 +67,18 @@ def planner_user_prompt(
|
||||
goal: str,
|
||||
scene_json: dict[str, Any],
|
||||
history_summary: list[dict[str, Any]],
|
||||
device_platform: str | None = None,
|
||||
now: datetime | None = None,
|
||||
) -> str:
|
||||
current_time = now or datetime.now().astimezone()
|
||||
if current_time.tzinfo is None:
|
||||
current_time = current_time.astimezone()
|
||||
timezone_name = current_time.tzname() or str(current_time.tzinfo) or "unknown"
|
||||
return (
|
||||
"Execution context:\n"
|
||||
f"Current date and time: {current_time.isoformat(timespec='seconds')}\n"
|
||||
f"Time zone: {timezone_name}\n"
|
||||
f"Device type: {_device_type(scene_json, device_platform)}\n\n"
|
||||
"Goal:\n"
|
||||
f"{goal}\n\n"
|
||||
"Current Scene (JSON):\n"
|
||||
@@ -76,3 +87,16 @@ def planner_user_prompt(
|
||||
f"{json.dumps(history_summary, ensure_ascii=False, sort_keys=True)}\n\n"
|
||||
"Call exactly one tool for this turn."
|
||||
)
|
||||
|
||||
|
||||
def _device_type(scene_json: dict[str, Any], device_platform: str | None) -> str:
|
||||
platform = device_platform
|
||||
if platform is None:
|
||||
app = scene_json.get("app")
|
||||
if isinstance(app, dict):
|
||||
raw_platform = app.get("platform")
|
||||
platform = raw_platform if isinstance(raw_platform, str) else None
|
||||
if not isinstance(platform, str):
|
||||
return "unknown"
|
||||
normalized = platform.strip().lower()
|
||||
return normalized if normalized in {"ios", "android"} else "unknown"
|
||||
|
||||
Reference in New Issue
Block a user