1 Star 0 Fork 0

O疯O/my_chatglm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
chatglm3_utils.py 803 Bytes
一键复制 编辑 原始数据 按行查看 历史
wfhe 提交于 2024-01-16 15:14 . tool examples
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
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wfhe/my_chatglm.git
git@gitee.com:wfhe/my_chatglm.git
wfhe
my_chatglm
my_chatglm
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385