Files
MoFin/venv/lib/python3.12/site-packages/litellm/proxy/video_endpoints/utils.py
T
知微 fa45d8aa5f fix: 小果地址统一node122(兼容LAN+EasyTier)
- health_checklist.json: 192.168.1.122→node122
- ocr_client.py: docstring IP→node122
- docs/market-data-requirements.md: IP→node122
- 所有API调用通过ProxyHandler({})绕过系统代理
  Privoxy对node122:18003返回500,直连正常
2026-06-30 02:56:35 +08:00

59 lines
1.9 KiB
Python

from typing import Any, Dict, Optional
import orjson
from litellm.types.videos.utils import encode_character_id_with_provider
def extract_model_from_target_model_names(target_model_names: Any) -> Optional[str]:
if isinstance(target_model_names, str):
target_model_names = [
m.strip() for m in target_model_names.split(",") if m.strip()
]
elif not isinstance(target_model_names, list):
return None
return target_model_names[0] if target_model_names else None
def get_custom_provider_from_data(data: Dict[str, Any]) -> Optional[str]:
custom_llm_provider = data.get("custom_llm_provider")
if custom_llm_provider:
return custom_llm_provider
extra_body = data.get("extra_body")
if isinstance(extra_body, str):
try:
parsed_extra_body = orjson.loads(extra_body)
if isinstance(parsed_extra_body, dict):
extra_body = parsed_extra_body
except Exception:
extra_body = None
if isinstance(extra_body, dict):
extra_body_custom_llm_provider = extra_body.get("custom_llm_provider")
if isinstance(extra_body_custom_llm_provider, str):
return extra_body_custom_llm_provider
return None
def encode_character_id_in_response(
response: Any, custom_llm_provider: str, model_id: Optional[str]
) -> Any:
if isinstance(response, dict) and response.get("id"):
response["id"] = encode_character_id_with_provider(
character_id=response["id"],
provider=custom_llm_provider,
model_id=model_id,
)
return response
character_id = getattr(response, "id", None)
if isinstance(character_id, str) and character_id:
response.id = encode_character_id_with_provider(
character_id=character_id,
provider=custom_llm_provider,
model_id=model_id,
)
return response