MCPcopy Create free account
hub / github.com/c76d3656e/rscholar / create_task

Function create_task

api_request.py:52–69  ·  view source on GitHub ↗

提交搜索任务,返回 task_id

(keyword: str, content_help: str, extra: dict)

Source from the content-addressed store, hash-verified

50
51
52def create_task(keyword: str, content_help: str, extra: dict) -> str | None:
53 """提交搜索任务,返回 task_id"""
54 payload = {
55 "keyword": keyword,
56 "content_help": content_help,
57 **extra,
58 }
59 try:
60 resp = requests.post(TASKS_URL, json=payload, timeout=30)
61 resp.raise_for_status()
62 data = resp.json()
63 task_id = data["task_id"]
64 eta = data.get("eta_seconds", "?")
65 print(f" ✓ Task created: {task_id} (ETA ~{eta}s)")
66 return task_id
67 except requests.RequestException as e:
68 print(f" ✗ Failed to create task: {e}", file=sys.stderr)
69 return None
70
71
72def poll_tasks(tracker: dict[str, dict]) -> None:

Callers 1

mainFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected