Skip to content

Commit ea325c7

Browse files
nileshpatil6i-yliu
authored andcommitted
fix(LiteLlm): recognize assistant- prefix as valid OpenAI file ID
Merge #5758 Original PR by @nileshpatil6 (Nilesh Patil <128893479+nileshpatil6@users.noreply.github.com>) Azure OpenAI files receive IDs with an `assistant-` prefix (e.g. `assistant-abc123`) or `file-` prefix. When `_looks_like_openai_file_id` recognizes an `assistant-` prefixed ID (e.g., `assistant-abc123`) or `file-` prefixed ID, `_redact_file_uri_for_log` defaulted to logging both as `file - <redacted>`. Fix: refactor `_redact_file_uri_for_log` to dynamically extract file ID prefixes (`file-`, `assistant-`). This ensures compatibility with both current prefixes and future OpenAI/Azure file ID types. Fixes #5664 Co-authored-by: Yi Liu <yiliuly@google.com> PiperOrigin-RevId: 933931477
1 parent fe08a9f commit ea325c7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/google/adk/models/lite_llm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ def _redact_file_uri_for_log(
398398
if file_uri.startswith("assistant-"):
399399
return "assistant-<redacted>"
400400
if _looks_like_openai_file_id(file_uri):
401-
return "file-<redacted>"
401+
prefix = file_uri.split("-", 1)[0]
402+
return f"{prefix}-<redacted>"
402403
try:
403404
parsed = urlparse(file_uri)
404405
except ValueError:

0 commit comments

Comments
 (0)