id: langflow
name: "Langflow"
version: "1.2"
description: "Visueller LLM Flow Builder mit KI-Integrationen"
category: education

links:
  homepage: "https://www.langflow.org/"
  docs: "https://docs.langflow.org/"
  github: "https://github.com/langflow-ai/langflow"

image:
  name: "langflowai/langflow"
  tag: "latest"

# IT.Box Custom Components (automatisch heruntergeladen)
binaries:
  - id: langflow/__init__.py
    destination: "/opt/appctl/data/langflow/components/IT.Box/__init__.py"
    mode: "0644"
  - id: langflow/itbox_llm.py
    destination: "/opt/appctl/data/langflow/components/IT.Box/itbox_llm.py"
    mode: "0644"
  - id: langflow/itbox_docling_convert.py
    destination: "/opt/appctl/data/langflow/components/IT.Box/itbox_docling_convert.py"
    mode: "0644"
  - id: langflow/itbox_agent.py
    destination: "/opt/appctl/data/langflow/components/IT.Box/itbox_agent.py"
    mode: "0644"
  - id: langflow/itbox_brave_search.py
    destination: "/opt/appctl/data/langflow/components/IT.Box/itbox_brave_search.py"
    mode: "0644"

ports:
  - host: 8320
    container: 7860
    protocol: tcp
    description: "Web-UI"

volumes:
  - host: "/opt/appctl/data/langflow"
    container: "/app/langflow"
    description: "Flows, Datenbank und Komponenten"

# Globale IT.Box Variablen
global_env:
  - key: "ITBOX_LLM_ENDPOINT"
    description: "IT.Box LLM-Proxy Endpoint"
    required: true
    default: "https://llm.kibox.online/v1"

  - key: "ITBOX_LLM_API_KEY"
    description: "IT.Box LLM API Key"
    required: true

  - key: "QDRANT_API_KEY"
    description: "Qdrant API Key (von Qdrant-Container)"
    required: true

environment:
  # === Server-Konfiguration ===
  - key: "LANGFLOW_HOST"
    value: "0.0.0.0"

  - key: "LANGFLOW_PORT"
    value: "7860"

  # === Custom Components ===
  - key: "LANGFLOW_COMPONENTS_PATH"
    value: "/app/langflow/components"

  # === Sicherheit & Authentifizierung ===
  - key: "LANGFLOW_SECRET_KEY"
    value: "${LANGFLOW_SECRET_KEY}"

  - key: "LANGFLOW_SUPERUSER"
    value: "admin"

  - key: "LANGFLOW_SUPERUSER_PASSWORD"
    value: "${LANGFLOW_SUPERUSER_PASSWORD}"

  # Auto-Login für Schulen (kein Login-Prompt)
  - key: "LANGFLOW_AUTO_LOGIN"
    value: "false"

  # === LLM-Provider: IT.Box LLM Proxy (OpenAI-kompatibel) ===
  - key: "LLM_ENDPOINT"
    value: "${ITBOX_LLM_ENDPOINT}"

  - key: "LLM_API_KEY"
    value: "${ITBOX_LLM_API_KEY}"

  # === Qdrant Vector Store (automatische Anbindung) ===
  # Langflow erkennt diese als Global Variables
  - key: "QDRANT_URL"
    value: "http://qdrant:6333"

  - key: "QDRANT_API_KEY"
    value: "${QDRANT_API_KEY}"

  # === Embedding Model (für RAG mit Qdrant) ===
  # IT.Box LLM Proxy stellt bge-m3 bereit
  - key: "EMBEDDING_MODEL"
    value: "bge-m3"

  # === Docling Document Processing (optional) ===
  # /v1/convert - Dokument zu Text/Markdown
  # /v1/chunk - Dokument zu RAG-ready Chunks
  - key: "DOCLING_ENDPOINT"
    value: "${ITBOX_LLM_ENDPOINT}"

  - key: "DOCLING_API_KEY"
    value: "${ITBOX_LLM_API_KEY}"

  # === Globale Variablen aus ENV importieren ===
  # Macht alle diese Variablen in Langflow UI verfügbar
  - key: "LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT"
    value: "LLM_ENDPOINT,LLM_API_KEY,QDRANT_URL,QDRANT_API_KEY,EMBEDDING_MODEL,DOCLING_ENDPOINT,DOCLING_API_KEY,WOLFRAM_ALPHA_APPID,BRAVE_SEARCH_API_KEY"

  # === Weitere Konfigurationen ===
  - key: "LANGFLOW_AUTO_SAVING"
    value: "true"

  - key: "LANGFLOW_LOG_LEVEL"
    value: "info"

  - key: "DO_NOT_TRACK"
    value: "true"

secrets:
  - key: "LANGFLOW_SECRET_KEY"
    description: "Secret Key für Verschlüsselung der Global Variables"
    required: true
    generate: "secret"

  - key: "LANGFLOW_SUPERUSER_PASSWORD"
    description: "Admin-Passwort für Langflow"
    required: true
    generate: "password"

# Optionale API Keys für externe Services
optional_secrets:
  - key: "WOLFRAM_ALPHA_APPID"
    description: "Wolfram Alpha App ID für mathematische Berechnungen"
    docs: "https://products.wolframalpha.com/api"

  - key: "BRAVE_SEARCH_API_KEY"
    description: "Brave Search API Key für Web-Suchen"
    docs: "https://brave.com/search/api/"

# Qdrant als Dependency für RAG-Features
# Embeddings via IT.Box LLM Proxy (bge-m3)
depends_on:
  - qdrant

post_install:
  messages:
    - "Langflow laeuft auf http://itbox.local:8320"
    - "Auto-Login aktiviert - Direkter Zugang ohne Anmeldung"
    - "IT.Box Custom Components installiert: LLM, Agent, Docling Convert, Brave Suche"
    - "IT.Box LLM-Proxy ist vorkonfiguriert (Chat + Embeddings)"
    - "Qdrant Vector Store automatisch verbunden (RAG-ready)"
    - "Embedding Model: bge-m3 (1024 Dimensionen)"
    - "Docling-Endpunkte verfuegbar: /v1/convert + /v1/chunk"
    - "Alle Variablen in Langflow UI unter Globe-Icon verfuegbar"
    - "API Keys nachtraeglich aendern: sudo nano /opt/appctl/compose/.env"
    - "Nach Aenderungen Container neu starten: sudo appctl restart langflow"

  ports_info:
    - port: 8320
      protocol: tcp
      description: "Web-UI - Für Tunnel: sudo tnl add langflow 8320"

resources:
  ram_mb: 512
  cpu_cores: 0.5
  disk_mb: 200

warnings:
  - "Auto-Login aktiviert - fuer Produktivumgebungen Authentifizierung konfigurieren"
  - "Benoetigt Qdrant fuer RAG-Features (wird automatisch installiert)"
