import asyncio
import json
import sys
import types

from fastapi import HTTPException

from main import DocumentParseRequest, parse_document


PAYLOAD = {
    "urls": [
        "http://192.168.252.71:48080/admin-api/infra/file/24/get/d7ade63d9599ec4a81b2671df2d8fa48a117cfda96d0396cc8e405d0b9c1a89b.docx"
    ],
    "conversation_id": "0edb7152426b4c298270434f2f8810cd",
    "ruleset_id": "金盘",
}


async def main() -> None:
    try:
        result = await parse_document(DocumentParseRequest(**PAYLOAD))
    except HTTPException as exc:
        print(
            json.dumps(
                {
                    "type": "HTTPException",
                    "status_code": exc.status_code,
                    "detail": exc.detail,
                },
                ensure_ascii=False,
                indent=2,
            )
        )
        return

    print(result.model_dump_json(indent=2))


if __name__ == "__main__":
    asyncio.run(main())
