# -*- coding: utf-8 -*-
# filename: constants.py
# @Time    : 2025-01-16
# @Author  : Claude Code
# @Email   : noreply@anthropic.com
# @Software: PyCharm
"""Constants and configuration for image tools"""
from typing import Literal

# Supported generation models
SUPPORTED_GENERATION_MODELS = {
    "google/gemini-3-pro-image-preview",
    "bytedance-seed/seedream-4.5",
    "openai/gpt-5-image",
    "openai/gpt-5-image-mini",
    "black-forest-labs/flux.2-max",
    "black-forest-labs/flux.2-pro",
}

# Model parameter configuration
MODEL_PARAMETER_CONFIG = {
    # Gemini 3 Pro Image Preview
    "google/gemini-3-pro-image-preview": {
        "param_type": "image_config",
        "supports_aspect_ratio": True,
        "supports_image_size": True,
        "default_aspect_ratio": "1:1",
        "default_image_size": "1K",
    },
    # ByteDance Seedream
    "bytedance-seed/seedream-4.5": {
        "param_type": "image_config",
        "supports_aspect_ratio": True,
        "supports_image_size": False,
        "default_aspect_ratio": "1:1",
    },
    # OpenAI GPT-5 Image
    "openai/gpt-5-image": {
        "param_type": "openai_native",
        "supports_size": True,
        "supports_quality": True,
        "default_size": "1024x1024",
        "default_quality": "high",
    },
    "openai/gpt-5-image-mini": {
        "param_type": "openai_native",
        "supports_size": True,
        "supports_quality": True,
        "default_size": "1024x1024",
        "default_quality": "medium",
    },
    # FLUX.2 Max/Pro
    "black-forest-labs/flux.2-max": {
        "param_type": "image_config",
        "supports_aspect_ratio": True,
        "supports_image_size": False,
        "default_aspect_ratio": "1:1",
        "max_resolution": "4MP",
    },
    "black-forest-labs/flux.2-pro": {
        "param_type": "image_config",
        "supports_aspect_ratio": True,
        "supports_image_size": False,
        "default_aspect_ratio": "1:1",
        "max_resolution": "4MP",
    },
}

# Supported understanding models
# pylint: disable=invalid-name
SUPPORTED_UNDERSTANDING_MODELS = Literal[
    "glm-4.6v", "glm-4.6v-flashx", "glm-4.6v-flash"
]

UNDERSTANDING_MODEL_CONFIG = {
    "glm-4.6v": {
        "description": "智谱 GLM-4.6V 高性能视觉模型",
        "context_window": 128_000,
        "max_output_tokens": 8192,
        "vision_capabilities": [
            "image_understanding",
            "ocr",
            "object_detection",
            "chart_analysis",
        ],
        "recommended_for": "复杂视觉理解任务、高精度 OCR、图表分析",
    },
    "glm-4.6v-flash": {
        "description": "智谱 GLM-4.6V Flash 免费快速视觉模型",
        "context_window": 128_000,
        "max_output_tokens": 4096,
        "vision_capabilities": [
            "image_understanding",
            "ocr",
            "object_detection",
            "chart_analysis",
        ],
        "recommended_for": "免费快速图片理解、通用视觉分析任务",
    },
    "glm-4.6v-flashx": {
        "description": "智谱 GLM-4.6V FlashX 快速视觉模型",
        "context_window": 128_000,
        "max_output_tokens": 4096,
        "vision_capabilities": ["image_understanding", "ocr", "object_detection"],
        "recommended_for": "快速图片理解、实时分析",
    },
}

# Prompt templates for image understanding (only detailed level)
PROMPT_TEMPLATES = {
    "describe": "请全面分析这张图片，包括：1）主要对象和元素，2）场景和背景，3）颜色和光影，4）艺术风格，5）情感和氛围。",
    "ocr": "请详细提取图片中的所有文字内容，包括：1）正文内容，2）标题和标签，3）特殊符号和标记。请保持原始格式，注明文字的位置关系。",
    "detect_objects": "请全面识别图片中的对象，包括：1）主要物体，2）次要物体，3）背景元素，4）人物（如有），5）其他细节。请按重要性排序。",
    "analyze_chart": "请全面分析这个图表：1）图表类型和结构，2）坐标轴和图例说明，3）数据趋势和模式，4）关键数据点和异常值，5）结论和建议。",
    # 专用文件预览模板
    "describe_pdf": "这是 PDF 文档的前几页转换成的图片。请分析这些页面：1）文档结构和布局，2）标题、章节和层次，3）主要内容概要，4）表格、图表等特殊元素，5）关键信息提取。如果是学术论文，请说明研究主题、方法和结论；如果是技术文档，请说明技术要点；如果是其他类型文档，请根据内容给出合适的总结。",
    "describe_ppt": "这是 PPT 演示文稿的前几页转换成的图片。请分析这些幻灯片：1）每页的主题和标题，2）内容结构和要点，3）视觉设计风格，4）使用的图表和图像，5）整体演示逻辑。如果是产品介绍，请说明核心卖点；如果是技术分享，请说明关键技术点；如果是其他类型演示，请根据内容给出合适的总结。",
}

# Prompt enhancement model
PROMPT_ENHANCEMENT_MODEL = "glm-4.6v"

# Mode descriptions for text-to-image
TEXT_TO_IMAGE_MODE_DESCRIPTIONS = {
    "technical_architecture": "技术架构图 - 生成系统架构图、数据流图、时序图等技术文档图示",
    "design_mockup": "设计稿 - 生成 UI 设计稿、线框图、原型图等产品设计图",
    "promotional_material": "宣传物料 - 生成海报、banner、社交媒体配图等营销物料",
    "office_chart": "通用办公图表 - 生成信息图表、数据可视化、PPT 配图等办公场景图片",
    "custom": "自定义 - 不进行 prompt 增强，直接使用原始 prompt",
}

# Mode descriptions for image-to-image
IMAGE_TO_IMAGE_MODE_DESCRIPTIONS = {
    "content_adjustment": "内容调整 - 调整亮度、对比度、色彩平衡等整体画面",
    "element_replace": "元素替换 - 替换图中的人物、物体、背景等元素",
    "style_transfer": "风格转换 - 将图片转为油画、卡通、水彩等不同艺术风格",
    "text_modification": "文字修改 - 修改图片内的文字内容，保持原图风格",
    "custom": "自定义 - 不进行 prompt 增强，直接使用原始 prompt",
}
