Text Classification
Keras
English
Azerbaijani
prompt-injection
security
llm-security
document-security
retvec
cnn
tensorflow
fastapi
Eval Results (legacy)
Instructions to use MegrurNiftiyev/MyGuard-Prompt-Injection-Detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use MegrurNiftiyev/MyGuard-Prompt-Injection-Detector with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://MegrurNiftiyev/MyGuard-Prompt-Injection-Detector") - Notebooks
- Google Colab
- Kaggle
Download app/core/logging.py from MegrurNiftiyev/MyGuard-Prompt-Injection-Detector: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/app/core/logging.py
- Command line
-
hf download hf://MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/app/core/logging.py
-
curl -L -o logging.py https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/app/core/logging.py
1.29 kB
| """ | |
| Structured logging configuration. | |
| """ | |
| import logging | |
| import sys | |
| import json | |
| from datetime import datetime, timezone | |
| class JSONFormatter(logging.Formatter): | |
| """Emit log records as single-line JSON objects.""" | |
| def format(self, record: logging.LogRecord) -> str: | |
| log_entry = { | |
| "timestamp": datetime.now(timezone.utc).isoformat(), | |
| "level": record.levelname, | |
| "logger": record.name, | |
| "message": record.getMessage(), | |
| } | |
| if record.exc_info and record.exc_info[0] is not None: | |
| log_entry["exception"] = self.formatException(record.exc_info) | |
| return json.dumps(log_entry) | |
| def setup_logging(level: int = logging.INFO) -> None: | |
| """Configure root logger with structured JSON output to stderr.""" | |
| handler = logging.StreamHandler(sys.stderr) | |
| handler.setFormatter(JSONFormatter()) | |
| root = logging.getLogger() | |
| root.setLevel(level) | |
| root.addHandler(handler) | |
| # Quieten noisy third-party loggers | |
| logging.getLogger("uvicorn.access").setLevel(logging.WARNING) | |
| logging.getLogger("motor").setLevel(logging.WARNING) | |
| def get_logger(name: str) -> logging.Logger: | |
| """Return a named logger.""" | |
| return logging.getLogger(name) | |