|
@@ -64,20 +64,25 @@ def _fetch_channel_by_content_id(content_id: str) -> Optional[str]:
|
|
|
|
|
|
|
|
|
def _upload_chunk(text: str, query: str, channel: str = "", max_retries: int = 3, backoff_sec: float = 1.0) -> bool:
|
|
|
+ # ext 需要是字符串 JSON
|
|
|
payload = {
|
|
|
"dataset_id": DATASET_ID,
|
|
|
"title": "",
|
|
|
"text": text,
|
|
|
- "ext": {"query": query, "channel": channel or ""},
|
|
|
+ "ext": json.dumps({"query": query, "channel": channel or ""}, ensure_ascii=False),
|
|
|
}
|
|
|
headers = {"Content-Type": "application/json"}
|
|
|
|
|
|
for attempt in range(max_retries):
|
|
|
try:
|
|
|
- resp = requests.get(CHUNK_API_URL, headers=headers, data=payload, timeout=30)
|
|
|
- # 打印出请求体
|
|
|
+ # 以 GET 方法发送,body 为 JSON 字符串
|
|
|
+ body = json.dumps(payload, ensure_ascii=False)
|
|
|
+ resp = requests.get(CHUNK_API_URL, headers=headers, data=body, timeout=30)
|
|
|
logger.info(f"上传chunk请求体: payload={payload}")
|
|
|
- logger.info(f"上传chunk成功: resp={resp.json()}")
|
|
|
+ try:
|
|
|
+ logger.info(f"上传chunk成功: resp={resp.json()}")
|
|
|
+ except Exception:
|
|
|
+ logger.info(f"上传chunk返回非JSON: text={resp.text[:500]}")
|
|
|
if resp.status_code >= 200 and resp.status_code < 300:
|
|
|
return True
|
|
|
logger.warning(f"上传失败,状态码: {resp.status_code}, 第{attempt+1}次重试")
|