feat: 移除所有 API 接口中的 post_id 回报
This commit is contained in:
1 parent
1718758713
commit
952fb2dc09
3 files changed
+5
-27
No files matched your search
@@ -954,9 +954,6 @@ async def chat_completions(request: ChatCompletionRequest, raw_request: Request)
|
||||
"completion_tokens": usage_completion,
|
||||
"total_tokens": usage_total,
|
||||
}
|
||||
# [NEW] 包含 post_id (取第一个结果的)
|
||||
if results and results[0].get("post_id"):
|
||||
merged["post_id"] = results[0]["post_id"]
|
||||
|
||||
result = merged
|
||||
|
||||
|
||||
+3
-17
@@ -558,12 +558,10 @@ async def _generate_nsfw_inner(data: NSFWRequest) -> Dict[str, Any]:
|
||||
"index": index,
|
||||
"image_url": image_url,
|
||||
"parent_post_id": parent_post_id,
|
||||
"post_id": task_post_id,
|
||||
"error": "parent_post_video_not_ready",
|
||||
"url": "",
|
||||
"poster_url": "",
|
||||
"content": video_content,
|
||||
"raw_response": raw_video_response,
|
||||
}
|
||||
return {
|
||||
"index": index,
|
||||
@@ -571,19 +569,16 @@ async def _generate_nsfw_inner(data: NSFWRequest) -> Dict[str, Any]:
|
||||
"content": video_content,
|
||||
"url": _clean_url(video_url),
|
||||
"poster_url": _clean_url(poster_url),
|
||||
"raw_response": raw_video_response,
|
||||
"parent_post_id": parent_post_id,
|
||||
"post_id": task_post_id,
|
||||
}
|
||||
except Exception as e:
|
||||
logger.warning(f"NSFW video failed: {task_tag}, error={e}")
|
||||
# 从 processor 中尝试挽救 post_id
|
||||
# 从 processor 中尝试挽救 post_id (内部记录用,不再返回)
|
||||
rescue_post_id = getattr(locals().get("processor"), "video_post_id", "") or task_post_id
|
||||
return {
|
||||
"index": index,
|
||||
"image_url": image_url,
|
||||
"parent_post_id": parent_post_id,
|
||||
"post_id": rescue_post_id,
|
||||
"error": str(e),
|
||||
"url": "",
|
||||
"poster_url": "",
|
||||
@@ -615,17 +610,8 @@ async def _generate_nsfw_inner(data: NSFWRequest) -> Dict[str, Any]:
|
||||
clean_links.append(cu)
|
||||
|
||||
lines = ["返回链接:"]
|
||||
for idx, u in enumerate(images, 1):
|
||||
lines.append(f"{idx}. (Image) {u}")
|
||||
|
||||
for idx, item in enumerate(video_results, 1):
|
||||
v_url = _clean_url(item.get("url", ""))
|
||||
p_id = item.get("post_id", "")
|
||||
if v_url:
|
||||
msg = f"{idx}. (Video) {v_url}"
|
||||
if p_id:
|
||||
msg += f" (post_id: {p_id})"
|
||||
lines.append(msg)
|
||||
for idx, u in enumerate(clean_links, 1):
|
||||
lines.append(f"{idx}. {u}")
|
||||
|
||||
response_payload["result"] = "\n".join(lines)
|
||||
return response_payload
|
||||
|
||||
@@ -994,7 +994,7 @@ class VideoStreamProcessor(BaseProcessor):
|
||||
logger.warning(f"Video upscale failed: {e}")
|
||||
return video_url
|
||||
|
||||
def _sse(self, content: str = "", role: str = None, finish: str = None, post_id: str = None) -> str:
|
||||
def _sse(self, content: str = "", role: str = None, finish: str = None) -> str:
|
||||
"""Build SSE response."""
|
||||
delta = {}
|
||||
if role:
|
||||
@@ -1002,9 +1002,6 @@ class VideoStreamProcessor(BaseProcessor):
|
||||
delta["content"] = ""
|
||||
elif content:
|
||||
delta["content"] = content
|
||||
|
||||
if post_id:
|
||||
delta["post_id"] = post_id
|
||||
|
||||
chunk = {
|
||||
"id": self.response_id or f"chatcmpl-{uuid.uuid4().hex[:24]}",
|
||||
@@ -1096,7 +1093,7 @@ class VideoStreamProcessor(BaseProcessor):
|
||||
rendered = await dl_service.render_video(
|
||||
video_url, self.token, thumbnail_url
|
||||
)
|
||||
yield self._sse(rendered, post_id=video_post_id)
|
||||
yield self._sse(rendered)
|
||||
|
||||
logger.info(f"Video generated: {video_url} (post_id={video_post_id})")
|
||||
continue
|
||||
@@ -1400,13 +1397,11 @@ class VideoCollectProcessor(BaseProcessor):
|
||||
"role": "assistant",
|
||||
"content": content,
|
||||
"refusal": None,
|
||||
"post_id": post_id,
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0},
|
||||
"post_id": post_id,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user