test_api.py 612 B

123456789101112131415161718192021
  1. import asyncio
  2. import httpx
  3. import json
  4. async def test():
  5. async with httpx.AsyncClient(timeout=10) as client:
  6. resp = await client.get(
  7. "http://8.147.104.190:8001/api/agent/search",
  8. params={
  9. "q": "科幻",
  10. "source_type": "实质",
  11. "entity_type": "all",
  12. "top_k": 2,
  13. "use_description": "true",
  14. }
  15. )
  16. data = resp.json()
  17. with open("test_api_output.json", "w", encoding="utf-8") as f:
  18. json.dump(data, f, ensure_ascii=False, indent=2)
  19. asyncio.run(test())