# Copyright (c) 2025 Patrick Motsch
# AI node definitions - map to methodAi actions.

from modules.shared.i18nRegistry import t

AI_NODES = [
    {
        "id": "ai.prompt",
        "category": "ai",
        "label": t("Prompt"),
        "description": t("Prompt eingeben und KI führt aus"),
        "parameters": [
            {"name": "aiPrompt", "type": "string", "required": True, "frontendType": "textarea",
             "description": t("KI-Prompt")},
            {"name": "outputFormat", "type": "string", "required": False, "frontendType": "select",
             "frontendOptions": {"options": ["text", "json", "emailDraft"]},
             "description": t("Ausgabeformat"), "default": "text"},
            {"name": "documentList", "type": "string", "required": False, "frontendType": "hidden",
             "description": t("Dokumentenliste (via Wire oder DataRef)"), "default": ""},
            {"name": "context", "type": "string", "required": False, "frontendType": "hidden",
             "description": t("Kontext-Daten (via Wire oder DataRef)"), "default": ""},
            {"name": "simpleMode", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Einfacher Modus"), "default": True},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "AiResult", "TextResult", "Transit"]}},
        "outputPorts": {0: {"schema": "AiResult"}},
        "meta": {"icon": "mdi-robot", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "process",
    },
    {
        "id": "ai.webResearch",
        "category": "ai",
        "label": t("Web-Recherche"),
        "description": t("Recherche im Web"),
        "parameters": [
            {"name": "prompt", "type": "string", "required": True, "frontendType": "textarea",
             "description": t("Recherche-Anfrage")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "AiResult"}},
        "meta": {"icon": "mdi-magnify", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "webResearch",
    },
    {
        "id": "ai.summarizeDocument",
        "category": "ai",
        "label": t("Dokument zusammenfassen"),
        "description": t("Dokumentinhalt zusammenfassen"),
        "parameters": [
            {"name": "summaryLength", "type": "string", "required": False, "frontendType": "select",
             "frontendOptions": {"options": ["short", "medium", "long"]},
             "description": t("Kurz, mittel oder lang"), "default": "medium"},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "AiResult"}},
        "meta": {"icon": "mdi-file-document-outline", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "summarizeDocument",
    },
    {
        "id": "ai.translateDocument",
        "category": "ai",
        "label": t("Dokument übersetzen"),
        "description": t("Dokument in Zielsprache übersetzen"),
        "parameters": [
            {"name": "targetLanguage", "type": "string", "required": True, "frontendType": "select",
             "frontendOptions": {"options": ["en", "de", "fr", "it", "es", "pt", "nl"]},
             "description": t("Zielsprache")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "AiResult"}},
        "meta": {"icon": "mdi-translate", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "translateDocument",
    },
    {
        "id": "ai.convertDocument",
        "category": "ai",
        "label": t("Dokument konvertieren"),
        "description": t("Dokument in anderes Format konvertieren"),
        "parameters": [
            {"name": "targetFormat", "type": "string", "required": True, "frontendType": "select",
             "frontendOptions": {"options": ["pdf", "docx", "txt", "html", "md"]},
             "description": t("Zielformat")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "DocumentList"}},
        "meta": {"icon": "mdi-file-convert", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "convertDocument",
    },
    {
        "id": "ai.generateDocument",
        "category": "ai",
        "label": t("Dokument generieren"),
        "description": t("Dokument aus Prompt generieren"),
        "parameters": [
            {"name": "prompt", "type": "string", "required": True, "frontendType": "textarea",
             "description": t("Generierungs-Prompt")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "DocumentList"}},
        "meta": {"icon": "mdi-file-plus", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "generateDocument",
    },
    {
        "id": "ai.generateCode",
        "category": "ai",
        "label": t("Code generieren"),
        "description": t("Code aus Beschreibung generieren"),
        "parameters": [
            {"name": "prompt", "type": "string", "required": True, "frontendType": "textarea",
             "description": t("Code-Generierungs-Prompt")},
            {"name": "language", "type": "string", "required": False, "frontendType": "select",
             "frontendOptions": {"options": ["python", "javascript", "typescript", "java", "csharp", "go"]},
             "description": t("Programmiersprache"), "default": "python"},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "AiResult"}},
        "meta": {"icon": "mdi-code-tags", "color": "#9C27B0"},
        "_method": "ai",
        "_action": "generateCode",
    },
]
