2026-01-09 04:07:03 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
2026-01-23 20:03:44 +08:00
|
|
|
import base64
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
2026-01-09 04:07:03 +08:00
|
|
|
from vllm.entrypoints.utils import sanitize_message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sanitize_message():
|
|
|
|
|
assert (
|
|
|
|
|
sanitize_message("<_io.BytesIO object at 0x7a95e299e750>")
|
|
|
|
|
== "<_io.BytesIO object>"
|
|
|
|
|
)
|
2026-01-23 20:03:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def encode_base64_content_from_url(content_url: str) -> dict[str, str]:
|
|
|
|
|
with requests.get(content_url) as response:
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
result = base64.b64encode(response.content).decode("utf-8")
|
|
|
|
|
|
|
|
|
|
return {"url": f"data:image/jpeg;base64,{result}"}
|