autool/DroidBot/guiagent_core/constants.py
2026-06-17 19:44:18 +08:00

51 lines
1.6 KiB
Python

"""
Constants Module for GuiAgent Core
Configuration related to models (API keys, params) has been moved to KeyPool.
"""
from typing import List
from pathlib import Path
import sys
ROOT_DIR = Path(__file__).resolve().parent.parent.parent
if str(ROOT_DIR) not in sys.path:
sys.path.insert(0, str(ROOT_DIR))
from config_loader import load_config as load_autool_config
# ==============================================================================
# Constants
# ==============================================================================
MAX_HISTORY_LENGTH = 10 # Maximum conversation history length
IMAGE_PLACEHOLDER = "<image>" # Placeholder for images in conversation
RESOLUTION_PLACEHOLDER = "{{resolution}}" # Placeholder for resolution in prompts
def load_config(json_path: str = None):
"""从JSON文件加载配置"""
return load_autool_config(json_path)
CURRENT_MODEL_NAME = (
load_config().get("CURRENT_MODEL_NAME")
or load_config().get("model", {}).get("current_name", "")
or ""
)
# Models that use absolute coordinates (return actual pixel coordinates)
# instead of normalized coordinates [0-1000]
ABSOLUTE_COORD_MODELS: List[str] = ["claude-sonnet-4-5"]
def is_absolute_coord_model(model_name: str) -> bool:
"""
Determine if the specified model uses absolute coordinate mode.
Args:
model_name: The name of the model to check
Returns:
bool: True if the model uses absolute coordinates, False for normalized [0-1000]
"""
if not model_name:
return False
return model_name in ABSOLUTE_COORD_MODELS