chore: remove unused imports and fix function name conflicts (#5764)

- Remove unused imports in anthropic.py, tmdbv3api/__init__.py, tv.py, test files
- Rename conflicting function names in subscribe.py and webhook.py
- Clean up unused re-exports in tmdbv3api/__init__.py (15 unused exports)
- Apply consistent formatting across API endpoints
This commit is contained in:
DDSRem
2026-05-13 18:59:03 +08:00
committed by GitHub
parent fcf6e14ac9
commit 5a585839ba
34 changed files with 2974 additions and 1838 deletions
+21 -9
View File
@@ -51,11 +51,15 @@ def extract_text_and_images(content: Any) -> Tuple[str, List[str]]:
data = source.get("data")
media_type = source.get("media_type") or "image/png"
if data and str(data).strip():
image_urls.append(f"data:{media_type};base64,{str(data).strip()}")
image_urls.append(
f"data:{media_type};base64,{str(data).strip()}"
)
return "\n".join(text_parts).strip(), image_urls
def build_prompt(messages: List[Any], use_server_session: bool) -> Tuple[str, List[str]]:
def build_prompt(
messages: List[Any], use_server_session: bool
) -> Tuple[str, List[str]]:
system_texts: List[str] = []
transcript: List[str] = []
latest_user_text = ""
@@ -97,7 +101,9 @@ def build_prompt(messages: List[Any], use_server_session: bool) -> Tuple[str, Li
else:
prompt_parts.append("当前用户消息:\n请结合图片内容回复。")
return "\n\n".join(part for part in prompt_parts if part).strip(), latest_user_images
return "\n\n".join(
part for part in prompt_parts if part
).strip(), latest_user_images
def build_session_id(session_key: str, prefix: str) -> str:
@@ -153,18 +159,24 @@ def build_responses_input(
content = item.get("content")
messages.append({"role": role, "content": content})
elif item.get("role") and "content" in item:
messages.append({"role": item.get("role"), "content": item.get("content")})
messages.append(
{"role": item.get("role"), "content": item.get("content")}
)
return messages
if isinstance(input_data, dict) and input_data.get("role") and "content" in input_data:
messages.append({"role": input_data.get("role"), "content": input_data.get("content")})
if (
isinstance(input_data, dict)
and input_data.get("role")
and "content" in input_data
):
messages.append(
{"role": input_data.get("role"), "content": input_data.get("content")}
)
return messages
def build_anthropic_messages(
system: Any, messages: List[Any]
) -> List[Dict[str, Any]]:
def build_anthropic_messages(system: Any, messages: List[Any]) -> List[Dict[str, Any]]:
normalized: List[Dict[str, Any]] = []
system_text, _ = extract_text_and_images(system)
if system_text: