Upload folder using huggingface_hub
Browse files- Dockerfile +2 -1
- README.md +40 -0
- models.py +19 -2
- openenv_Ad_Audit.egg-info/PKG-INFO +9 -0
- openenv_Ad_Audit.egg-info/SOURCES.txt +20 -0
- openenv_Ad_Audit.egg-info/dependency_links.txt +1 -0
- openenv_Ad_Audit.egg-info/entry_points.txt +2 -0
- openenv_Ad_Audit.egg-info/requires.txt +5 -0
- openenv_Ad_Audit.egg-info/top_level.txt +1 -0
Dockerfile
CHANGED
|
@@ -71,11 +71,12 @@ ENV PATH="/app/.venv/bin:$PATH"
|
|
| 71 |
# Set PYTHONPATH so imports work correctly
|
| 72 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
| 73 |
|
|
|
|
|
|
|
| 74 |
# Health check
|
| 75 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 76 |
CMD curl -f http://localhost:8000/health || exit 1
|
| 77 |
|
| 78 |
# Run the FastAPI server
|
| 79 |
# The module path is constructed to work with the /app/env structure
|
| 80 |
-
ENV ENABLE_WEB_INTERFACE=true
|
| 81 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
|
|
|
|
| 71 |
# Set PYTHONPATH so imports work correctly
|
| 72 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
| 73 |
|
| 74 |
+
ENV ENABLE_WEB_INTERFACE=true
|
| 75 |
+
|
| 76 |
# Health check
|
| 77 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 78 |
CMD curl -f http://localhost:8000/health || exit 1
|
| 79 |
|
| 80 |
# Run the FastAPI server
|
| 81 |
# The module path is constructed to work with the /app/env structure
|
|
|
|
| 82 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
|
README.md
CHANGED
|
@@ -74,6 +74,46 @@ asyncio.run(main())
|
|
| 74 |
|
| 75 |
**Investigation tools:** click_timestamps, ip_distribution, device_fingerprints, referral_urls, viewability_scores, conversion_quality
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
## Observation
|
| 78 |
|
| 79 |
Each step returns:
|
|
|
|
| 74 |
|
| 75 |
**Investigation tools:** click_timestamps, ip_distribution, device_fingerprints, referral_urls, viewability_scores, conversion_quality
|
| 76 |
|
| 77 |
+
**Fraud types:** bot_traffic, domain_spoofing, click_injection
|
| 78 |
+
|
| 79 |
+
### Action input format
|
| 80 |
+
|
| 81 |
+
Each action is a JSON object with the fields below. Only include fields relevant to the chosen `action_type`.
|
| 82 |
+
|
| 83 |
+
| Field | Type | Used by | Example |
|
| 84 |
+
|-------|------|---------|---------|
|
| 85 |
+
| `action_type` | string (required) | all | `"monitor"` |
|
| 86 |
+
| `publisher_id` | string | investigate, flag | `"pub_001"` |
|
| 87 |
+
| `tool` | string | investigate | `"click_timestamps"` |
|
| 88 |
+
| `fraud_type` | string | flag | `"bot_traffic"` |
|
| 89 |
+
| `evidence` | list of strings | flag | `["click_timestamps", "ip_distribution"]` |
|
| 90 |
+
| `summary` | string | submit_report | `"Publisher pub_002 is running bot traffic"` |
|
| 91 |
+
|
| 92 |
+
**Examples:**
|
| 93 |
+
|
| 94 |
+
```json
|
| 95 |
+
{"action_type": "monitor"}
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
```json
|
| 99 |
+
{"action_type": "investigate_publisher", "publisher_id": "pub_001", "tool": "click_timestamps"}
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
```json
|
| 103 |
+
{
|
| 104 |
+
"action_type": "flag_fraud",
|
| 105 |
+
"publisher_id": "pub_002",
|
| 106 |
+
"fraud_type": "bot_traffic",
|
| 107 |
+
"evidence": ["click_timestamps", "ip_distribution"]
|
| 108 |
+
}
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
```json
|
| 112 |
+
{"action_type": "submit_report", "summary": "Flagged pub_002 for bot traffic based on timestamp clustering and IP concentration."}
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
> **Web UI note:** In the web interface, fill in only the fields for your chosen action and leave the rest blank. For the `evidence` field, enter tool names separated by commas (e.g. `click_timestamps, ip_distribution`).
|
| 116 |
+
|
| 117 |
## Observation
|
| 118 |
|
| 119 |
Each step returns:
|
models.py
CHANGED
|
@@ -6,7 +6,7 @@ Defines Action, Observation, and State types that conform to the OpenEnv spec.
|
|
| 6 |
|
| 7 |
from typing import Any, Dict, List, Literal, Optional
|
| 8 |
|
| 9 |
-
from pydantic import BaseModel, Field
|
| 10 |
|
| 11 |
from openenv.core.env_server.types import Action, Observation, State
|
| 12 |
|
|
@@ -47,9 +47,26 @@ class AdAuditAction(Action):
|
|
| 47 |
"click_injection",
|
| 48 |
]] = Field(default=None, description="Fraud type to flag")
|
| 49 |
evidence: Optional[List[str]] = Field(
|
| 50 |
-
default=None,
|
|
|
|
| 51 |
)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# submit_report
|
| 54 |
summary: Optional[str] = Field(default=None)
|
| 55 |
|
|
|
|
| 6 |
|
| 7 |
from typing import Any, Dict, List, Literal, Optional
|
| 8 |
|
| 9 |
+
from pydantic import BaseModel, Field, field_validator
|
| 10 |
|
| 11 |
from openenv.core.env_server.types import Action, Observation, State
|
| 12 |
|
|
|
|
| 47 |
"click_injection",
|
| 48 |
]] = Field(default=None, description="Fraud type to flag")
|
| 49 |
evidence: Optional[List[str]] = Field(
|
| 50 |
+
default=None,
|
| 51 |
+
description="Evidence tool names, comma-separated (e.g. click_timestamps, ip_distribution)",
|
| 52 |
)
|
| 53 |
|
| 54 |
+
@field_validator("evidence", mode="before")
|
| 55 |
+
@classmethod
|
| 56 |
+
def _coerce_evidence(cls, v):
|
| 57 |
+
if isinstance(v, str):
|
| 58 |
+
import json
|
| 59 |
+
try:
|
| 60 |
+
parsed = json.loads(v)
|
| 61 |
+
if isinstance(parsed, list):
|
| 62 |
+
return parsed
|
| 63 |
+
except (json.JSONDecodeError, ValueError):
|
| 64 |
+
pass
|
| 65 |
+
# Handle bare string like "click_timestamps"
|
| 66 |
+
stripped = v.strip("[] ")
|
| 67 |
+
return [s.strip().strip("'\"") for s in stripped.split(",") if s.strip()]
|
| 68 |
+
return v
|
| 69 |
+
|
| 70 |
# submit_report
|
| 71 |
summary: Optional[str] = Field(default=None)
|
| 72 |
|
openenv_Ad_Audit.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: openenv-Ad_Audit
|
| 3 |
+
Version: 0.1.0
|
| 4 |
+
Summary: Ad Audit environment for OpenEnv
|
| 5 |
+
Requires-Python: >=3.10
|
| 6 |
+
Requires-Dist: openenv-core[core]>=0.2.2
|
| 7 |
+
Provides-Extra: dev
|
| 8 |
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
| 9 |
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
openenv_Ad_Audit.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
README.md
|
| 2 |
+
pyproject.toml
|
| 3 |
+
./__init__.py
|
| 4 |
+
./client.py
|
| 5 |
+
./inference.py
|
| 6 |
+
./models.py
|
| 7 |
+
openenv_Ad_Audit.egg-info/PKG-INFO
|
| 8 |
+
openenv_Ad_Audit.egg-info/SOURCES.txt
|
| 9 |
+
openenv_Ad_Audit.egg-info/dependency_links.txt
|
| 10 |
+
openenv_Ad_Audit.egg-info/entry_points.txt
|
| 11 |
+
openenv_Ad_Audit.egg-info/requires.txt
|
| 12 |
+
openenv_Ad_Audit.egg-info/top_level.txt
|
| 13 |
+
server/Ad_Audit_environment.py
|
| 14 |
+
server/__init__.py
|
| 15 |
+
server/app.py
|
| 16 |
+
server/fraud_engine.py
|
| 17 |
+
server/grader.py
|
| 18 |
+
server/publisher_engine.py
|
| 19 |
+
server/response_generator.py
|
| 20 |
+
server/step_reward.py
|
openenv_Ad_Audit.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
openenv_Ad_Audit.egg-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
server = Ad_Audit.server.app:main
|
openenv_Ad_Audit.egg-info/requires.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openenv-core[core]>=0.2.2
|
| 2 |
+
|
| 3 |
+
[dev]
|
| 4 |
+
pytest>=8.0.0
|
| 5 |
+
pytest-cov>=4.0.0
|
openenv_Ad_Audit.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Ad_Audit
|