|
|
@@ -105,20 +105,19 @@ class SampleCenterClient:
|
|
|
resp = requests.get(url, headers=self._headers(), timeout=15)
|
|
|
return self._parse(resp)
|
|
|
|
|
|
- def batch_import(self, kb_id, task_no, parents, children=None, callback_url=None):
|
|
|
+ def batch_import(self, kb_id, task_no, parents=None, children=None, callback_url=None):
|
|
|
"""POST /api/v1/knowledge-bases/{kb_id}/batch-import -- 批量入库。"""
|
|
|
url = f"{self.base_url}/api/v1/knowledge-bases/{kb_id}/batch-import"
|
|
|
- payload = {
|
|
|
- "task_no": task_no,
|
|
|
- "parents": parents,
|
|
|
- }
|
|
|
+ payload = {"task_no": task_no}
|
|
|
+ if parents:
|
|
|
+ payload["parents"] = parents
|
|
|
if children:
|
|
|
payload["children"] = children
|
|
|
if callback_url:
|
|
|
payload["callback_url"] = callback_url
|
|
|
logger.info(
|
|
|
f"请求批量入库: url={url}, task_no={task_no}, "
|
|
|
- f"parents_count={len(parents)}, children_count={len(children) if children else 0}, "
|
|
|
+ f"parents_count={len(parents) if parents else 0}, children_count={len(children) if children else 0}, "
|
|
|
f"parents={parents!r}, children={children!r}, callback_url={callback_url}"
|
|
|
)
|
|
|
resp = requests.post(
|