代码拉取完成,页面将自动刷新
import chatglm_cpp
from PIL import Image
from typing import Optional
class Message:
def __init__(self, role: str, content: str, tool_calls: int, image: Optional[str] = None):
self.role = role
self.content = content
self.tool_calls = tool_calls
self.image = image
def from_cpp(cpp_chat_message: chatglm_cpp.ChatMessage) -> Message:
"""
将 C++ ChatMessage 对象转换为 Python Message 对象。
:param cpp_chat_message: C++ ChatMessage 对象
:return: Python Message 对象
"""
return Message(
role=cpp_chat_message.role,
content=cpp_chat_message.content,
tool_calls=cpp_chat_message.tool_calls,
image=None # 如果 image 总是 None,可以考虑在 Message 类中设置默认值 self.image = None
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。