mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Address bugbot: drop dead encode/decode helpers; preserve empty custom_id
- Remove unused _encode_gcp_label_value / _decode_gcp_label_value singular helpers; only the _chunks variants are actually called. - Use 'is not None' check for custom_id so empty-string custom_ids are still labeled and round-trip through batch outputs. Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
This commit is contained in:
parent
891445783c
commit
9275eea131
1 changed files with 1 additions and 17 deletions
|
|
@ -63,17 +63,6 @@ def _sanitize_gcp_label_value(value: str) -> str:
|
|||
return sanitized[:_GCP_LABEL_VALUE_MAX_LEN]
|
||||
|
||||
|
||||
def _encode_gcp_label_value(value: str) -> str:
|
||||
"""Encode arbitrary text into a GCP-label-safe value."""
|
||||
max_encoded_len = _GCP_LABEL_VALUE_MAX_LEN - len(_CUSTOM_ID_RAW_LABEL_PREFIX)
|
||||
encoded = (
|
||||
base64.b32encode(value.encode("utf-8")).decode("ascii").rstrip("=").lower()
|
||||
)
|
||||
if len(encoded) > max_encoded_len:
|
||||
raise ValueError("Encoded label value exceeds GCP label length")
|
||||
return f"{_CUSTOM_ID_RAW_LABEL_PREFIX}{encoded}"
|
||||
|
||||
|
||||
def _encode_gcp_label_value_chunks(value: str) -> List[str]:
|
||||
"""Encode arbitrary text across one or more GCP-label-safe values."""
|
||||
max_encoded_len = _GCP_LABEL_VALUE_MAX_LEN - len(_CUSTOM_ID_RAW_LABEL_PREFIX)
|
||||
|
|
@ -86,11 +75,6 @@ def _encode_gcp_label_value_chunks(value: str) -> List[str]:
|
|||
] or [_CUSTOM_ID_RAW_LABEL_PREFIX]
|
||||
|
||||
|
||||
def _decode_gcp_label_value(value: str) -> Optional[str]:
|
||||
"""Decode values produced by _encode_gcp_label_value."""
|
||||
return _decode_gcp_label_value_chunks([value])
|
||||
|
||||
|
||||
def _decode_gcp_label_value_chunks(values: List[str]) -> Optional[str]:
|
||||
"""Decode values produced by _encode_gcp_label_value_chunks."""
|
||||
encoded_parts = []
|
||||
|
|
@ -170,7 +154,7 @@ def _openai_batch_jsonl_entries_to_vertex_wrapped_requests(
|
|||
|
||||
# Add custom_id as a label for correlation in batch outputs
|
||||
custom_id = _openai_jsonl_content.get("custom_id")
|
||||
if custom_id:
|
||||
if custom_id is not None:
|
||||
if "labels" not in vertex_request_body:
|
||||
vertex_request_body["labels"] = {}
|
||||
_set_litellm_batch_custom_id_labels(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue