RecRedTeam AuditLab: static audit page, 234 cases x 8 defense combinations precomputed
ca949ba verified Download auditlab/types.py from NoahIsARider/RecRedTeam-AuditLab: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/spaces/NoahIsARider/RecRedTeam-AuditLab/resolve/main/auditlab/types.py
- Command line
-
hf download hf://spaces/NoahIsARider/RecRedTeam-AuditLab/auditlab/types.py
-
curl -L -o types.py https://huggingface.co/spaces/NoahIsARider/RecRedTeam-AuditLab/resolve/main/auditlab/types.py
2.59 kB
| """Data model for the audit engine.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from typing import Any, Dict, List | |
| class Product: | |
| pid: str | |
| name: str | |
| category: str | |
| price: float | |
| description: str | |
| seller: str | |
| seller_trust: float | |
| rating: float | |
| review_count: int | |
| reviews: List[str] = field(default_factory=list) | |
| tags: List[str] = field(default_factory=list) | |
| attrs: Dict[str, Any] = field(default_factory=dict) | |
| stock: int = 0 | |
| def from_dict(cls, d: Dict[str, Any]) -> "Product": | |
| return cls( | |
| pid=d.get("pid", ""), | |
| name=d.get("name", ""), | |
| category=d.get("category", ""), | |
| price=float(d.get("price", 0.0)), | |
| description=d.get("description", ""), | |
| seller=d.get("seller", ""), | |
| seller_trust=float(d.get("seller_trust", 0.5)), | |
| rating=float(d.get("rating", 0.0)), | |
| review_count=int(d.get("review_count", 0)), | |
| reviews=list(d.get("reviews", [])), | |
| tags=list(d.get("tags", [])), | |
| attrs=dict(d.get("attrs", {})), | |
| stock=int(d.get("stock", 0)), | |
| ) | |
| class AttackCase: | |
| attack_id: str | |
| category_id: str | |
| category_name: str | |
| category_name_cn: str | |
| owasp_asi: str | |
| owasp_llm: str | |
| severity: str | |
| name: str | |
| description: str | |
| user_query: str | |
| goal: str | |
| target_pid: str | |
| products: List[Product] | |
| hidden_instructions: Dict[str, str] | |
| failure_signals: List[str] | |
| source: str | |
| split: str | |
| def from_dict(cls, d: Dict[str, Any]) -> "AttackCase": | |
| return cls( | |
| attack_id=d["attack_id"], | |
| category_id=d["category_id"], | |
| category_name=d["category_name"], | |
| category_name_cn=d.get("category_name_cn", ""), | |
| owasp_asi=d["owasp_asi"], | |
| owasp_llm=d["owasp_llm"], | |
| severity=d["severity"], | |
| name=d["name"], | |
| description=d["description"], | |
| user_query=d["user_query"], | |
| goal=d["goal"], | |
| target_pid=d["target_pid"], | |
| products=[Product.from_dict(p) for p in d.get("products", [])], | |
| hidden_instructions=dict(d.get("hidden_instructions", {})), | |
| failure_signals=[s for s in d.get("failure_signals", []) if s], | |
| source=d.get("source", "template"), | |
| split=d.get("split", "public"), | |
| ) | |