Skip to content

s02的normalize函数是不是有点问题 #218

@meichiguozhuro

Description

@meichiguozhuro

下面是一个日志:
normalize前原始消息历史:[{'role': 'user', 'content': '你好'}, {'role': 'assistant', 'content': [TextBlock(citations=None, text='你好!很高兴见到你!有什么我可以帮助你的吗?', type='text')]}, {'role': 'user', 'content': '帮我在D盘创建一个txt文件'}]
normalize后消息历史:[{'role': 'user', 'content': '你好'}, {'role': 'assistant', 'content': []}, {'role': 'user', 'content': '帮我在D盘创建一个txt文件'}]

可见TextBlock被清洗掉了

是不是因为这部分代码 cleaned = []
for msg in messages:
clean = {"role": msg["role"]}
if isinstance(msg.get("content"), str):
clean["content"] = msg["content"]
elif isinstance(msg.get("content"), list):
clean["content"] = [
{k: v for k, v in block.items()
if not k.startswith("_")}
for block in msg["content"]
if isinstance(block, dict)
]
else:
clean["content"] = msg.get("content", "")
cleaned.append(clean)
这一行if isinstance(block, dict)无法兼容返回的TextBlock类

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions