Signed-off-by: Sy03 <1370724210@qq.com> Co-authored-by: shimei.jmh <shimei.jmh@taobao.com> Co-authored-by: SYLAR <125541396+lishunyang12@users.noreply.github.com>
This commit is contained in:
14 files changed
+3597
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Small helpers shared by streaming video handlers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def text_only_message(message: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Return a history message with multimodal content stripped out."""
|
||||
role = message.get("role", "user")
|
||||
content = message.get("content", "")
|
||||
|
||||
if isinstance(content, str):
|
||||
return {"role": role, "content": content}
|
||||
|
||||
if not isinstance(content, list):
|
||||
return {"role": role, "content": ""}
|
||||
|
||||
text_parts: list[str] = []
|
||||
for part in content:
|
||||
if isinstance(part, dict) and part.get("type") == "text":
|
||||
text = part.get("text")
|
||||
if isinstance(text, str):
|
||||
text_parts.append(text)
|
||||
|
||||
return {"role": role, "content": "".join(text_parts)}
|
||||
Reference in new issue
Block a user