AI计价规则BUG修复
This commit is contained in:
@@ -80,7 +80,15 @@ def _walk_reference_items(value: Any) -> Iterable[Mapping[str, Any]]:
|
||||
yield from _walk_reference_items(child)
|
||||
|
||||
|
||||
def _billable_input(raw: Mapping[str, Any], media_type: str) -> bool:
|
||||
def _billable_input(
|
||||
raw: Mapping[str, Any],
|
||||
media_type: str,
|
||||
*,
|
||||
allow_provider_input: bool,
|
||||
) -> bool:
|
||||
# 是否作为供应商直接输入由服务端调用链决定,不能信任客户端附件字段。
|
||||
if not allow_provider_input:
|
||||
return False
|
||||
if "billable_input" in raw:
|
||||
return safe_bool(raw.get("billable_input"), True)
|
||||
role = str(raw.get("role") or raw.get("label") or raw.get("reference_role") or "").lower()
|
||||
@@ -89,7 +97,11 @@ def _billable_input(raw: Mapping[str, Any], media_type: str) -> bool:
|
||||
return media_type in MEDIA_TYPES
|
||||
|
||||
|
||||
def build_attachment_snapshot(media_references: Any) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
def build_attachment_snapshot(
|
||||
media_references: Any,
|
||||
*,
|
||||
allow_provider_input: bool = True,
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
items: list[dict[str, Any]] = []
|
||||
image_count = video_count = audio_count = 0
|
||||
provider_input_image_count = 0
|
||||
@@ -118,7 +130,11 @@ def build_attachment_snapshot(media_references: Any) -> tuple[dict[str, Any], di
|
||||
seen.add(dedupe_key)
|
||||
|
||||
duration = max(0.0, safe_float(raw.get("duration"), safe_float(raw.get("duration_seconds"))))
|
||||
billable = _billable_input(raw, media_type)
|
||||
billable = _billable_input(
|
||||
raw,
|
||||
media_type,
|
||||
allow_provider_input=allow_provider_input,
|
||||
)
|
||||
item = {
|
||||
"type": media_type,
|
||||
"role": raw.get("role") or raw.get("label") or raw.get("reference_role"),
|
||||
|
||||
Reference in New Issue
Block a user