---
name: llm-guardrails
#region classifiers
classifiers:
  secrets0:
    type: patterns
    options:
      entropy: 3.0
      labels:
        secret.aws_key: "AKIA[0-9A-Z]{16}"
        secret.github_token: "ghp_[A-Za-z0-9]{36}"
  pii0:
    type: presidio
    options:
      endpoint: http://presidio-analyzer:3000
      language: en
      threshold: 0.6
      timeout: PT5S
      labels:
        email: EMAIL_ADDRESS
#endregion classifiers
guards:
  api_key:
    type: inline
bindings:
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port: 7161
    exit: north_http_server
  north_http_server:
    type: http
    kind: server
    exit: north_llm_server
  north_llm_server:
    type: llm
    kind: server
    options:
      dialect: openai
      authorization:
        api_key:
          credentials: "Bearer {credentials}"
    exit: north_llm_proxy
  #region llm_proxy
  north_llm_proxy:
    type: llm
    kind: proxy
    options:
      guardrails:
        gpt-4o-mini:
          request:
            - section: user-text
              value:
                model: string
                maxLength: 2000
            - section: user-text
              value:
                model: classify
                reject:
                  secrets0:
                    - secret.aws_key
                    - secret.github_token
                  pii0:
                    - email
    routes:
      - when:
          - model:
              - gpt-*
        exit: south_llm_client_openai
  #endregion llm_proxy
  south_llm_client_openai:
    type: llm
    kind: client
    options:
      dialect: openai
      server: https://api.openai.com
      authorization:
        api_key:
          credentials: "Bearer {credentials}"
    exit: sys:http_client
