langdb_core 0.3.2

AI gateway Core for LangDB AI Gateway.
Documentation
{
  "guardrail_examples": {
    "content_filter": {
      "name": "content_filter",
      "type": "guardrail",
      "guard_id": "content_safety",
      "config": {
        "enabled": true,
        "threshold": 0.8,
        "rules": ["no_harmful_content", "no_hate_speech"],
        "guardrail_type": "content_filter"
      }
    },
    
    "toxicity_filter": {
      "name": "toxicity_filter",
      "type": "guardrail",
      "guard_id": "toxicity_detection",
      "config": {
        "enabled": true,
        "threshold": 0.7,
        "guardrail_type": "toxicity",
        "categories": ["hate_speech", "violence", "harassment", "discrimination"]
      }
    },
    
    "semantic_filter": {
      "name": "semantic_filter",
      "type": "guardrail",
      "guard_id": "semantic_safety",
      "config": {
        "enabled": true,
        "threshold": 0.6,
        "guardrail_type": "semantic",
        "topics": ["medical_advice", "financial_advice", "legal_advice", "personal_advice"]
      }
    },
    
    "compliance_filter": {
      "name": "compliance_filter",
      "type": "guardrail",
      "guard_id": "compliance_check",
      "config": {
        "enabled": true,
        "threshold": 0.9,
        "guardrail_type": "compliance",
        "regulations": ["GDPR", "HIPAA", "SOX"],
        "data_classification": "sensitive"
      }
    },
    
    "pii_filter": {
      "name": "pii_filter",
      "type": "guardrail",
      "guard_id": "pii_detection",
      "config": {
        "enabled": true,
        "threshold": 0.8,
        "guardrail_type": "pii",
        "rules": ["no_ssn", "no_credit_card", "no_email", "no_phone"]
      }
    },
    
    "bias_filter": {
      "name": "bias_filter",
      "type": "guardrail",
      "guard_id": "bias_detection",
      "config": {
        "enabled": true,
        "threshold": 0.7,
        "guardrail_type": "bias",
        "categories": ["gender_bias", "racial_bias", "age_bias", "religious_bias"]
      }
    }
  },
  
  "usage_in_routes": {
    "pre_request": [
      {
        "name": "content_filter",
        "type": "guardrail",
        "guard_id": "content_safety",
        "config": {
          "enabled": true,
          "threshold": 0.8,
          "guardrail_type": "content_filter"
        }
      },
      {
        "name": "toxicity_filter",
        "type": "guardrail",
        "guard_id": "toxicity_detection",
        "config": {
          "enabled": true,
          "threshold": 0.7,
          "guardrail_type": "toxicity",
          "categories": ["hate_speech", "violence"]
        }
      }
    ],
    
    "routes": [
      {
        "name": "safe_content_routing",
        "conditions": {
          "all": [
            {
              "pre_request.content_filter.passed": {
                "eq": true
              }
            },
            {
              "pre_request.toxicity_filter.passed": {
                "eq": true
              }
            }
          ]
        },
        "targets": {
          "$any": ["openai/gpt-4", "anthropic/claude-3-opus"]
        }
      },
      {
        "name": "filtered_content_routing",
        "conditions": {
          "any": [
            {
              "pre_request.content_filter.passed": {
                "eq": false
              }
            },
            {
              "pre_request.toxicity_filter.passed": {
                "eq": false
              }
            }
          ]
        },
        "targets": {
          "$any": ["openai/gpt-3.5-turbo"],
          "sort": {
            "cost": "MIN"
          }
        }
      }
    ]
  }
}