Upload agent/__main__.py with huggingface_hub
Browse files- agent/__main__.py +34 -0
agent/__main__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CLI driver — run `python -m agent <file>` to drive the audit without Streamlit.
|
| 2 |
+
|
| 3 |
+
Useful for local debugging. Prints each SSE event as one JSON line to stdout
|
| 4 |
+
so you can pipe it through `jq` or save to a transcript.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import asyncio
|
| 10 |
+
import sys
|
| 11 |
+
|
| 12 |
+
from agent.loop import run_audit
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
async def _drive(file_path: str) -> int:
|
| 16 |
+
rc = 0
|
| 17 |
+
async for event in run_audit(file_path):
|
| 18 |
+
# One event per line — newline-delimited JSON for easy `jq` use.
|
| 19 |
+
sys.stdout.write(event.model_dump_json() + "\n")
|
| 20 |
+
sys.stdout.flush()
|
| 21 |
+
if event.type == "error":
|
| 22 |
+
rc = 1
|
| 23 |
+
return rc
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def main() -> int:
|
| 27 |
+
if len(sys.argv) != 2:
|
| 28 |
+
sys.stderr.write("usage: python -m agent <path-to-config-or-script>\n")
|
| 29 |
+
return 2
|
| 30 |
+
return asyncio.run(_drive(sys.argv[1]))
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
raise SystemExit(main())
|