这是indexloc提供的服务,不要输入任何密码
Skip to content

使用流式输出stream_chat调用工具时返回异常 #1348

@aliang-123

Description

@aliang-123

System Info / 系統信息

python3.11 daiban系统

Who can help? / 谁可以帮助到您?

No response

Information / 问题信息

  • The official example scripts / 官方的示例脚本
  • My own modified scripts / 我自己修改的脚本和任务

Reproduction / 复现过程

`tools = [

    {
        "name": "base_info",
        "description": """查询指定影城的基础信息,包括影院开业时间、影厅数量、今年票房、排名、排座、历年票房表现等等一切影城维度的数据""",
        "parameters": {
            "type": "object",
            "properties": {
                "business_date_start": {
                    "description": "要查询的开始时间,格式为'yyyymmdd'的八位数字,非必传,可以为空",
                    "type": 'int'
                },
                "business_date_end": {
                    "description": "要查询的结束时间,格式为'yyyymmdd'的八位数字,非必传,可以为空",
                    "type": 'int'
                },
                "cinema_code": {
                    "description": "筛选的影城编码,非必传,可以为空",
                    "type": 'str'
                },
                "cinema_name": {
                    "description": "筛选的影城名称,非必传,可以为空",
                    'type': 'int'
                },
                "hasService": {
                    "description": "是否包含服务费,包含为1,不包含为0,非必传,默认为1",
                    "type": 'str'
                },
                "periodTime": {
                    "description": "时段 1:全天 2:黄金场,非必传,默认为1",
                    "type": 'str'
                },
            },
            "required": ['business_date_start', 'business_date_end', 'cinema_code', 'cinema_name', 'hasService',
                         'periodTime']
        }
    },
]

system_info = {
    "role": "system",
    "content": "Answer the following questions as best as you can. You have access to the following tools:",
    "tools": tools
}
messages = [system_info]
messages.append({"role": "system", "content": "不要假设或猜测传入函数的参数值。如果用户的描述不明确,请要求用户提供必要信息"})
messages.append({"role": "system", "content": "不要假设或猜测函数的返回值。如果无法理解返回值的含义,请将返回值完整展示给用户,并告诉用户无法理解,如果函数没有返回任何值,请告诉用户函数调用没有结果"})
messages.append({"role": "system", "content": "如果用户提供的信息不足以调用函数,请告诉用户需要的信息"})
messages.append({"role": "system", "content": "如果用户提供的信息没有涉及非必传参数,请使用默认值调用函数,并告诉用户已使用默认值"})

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True, )
model = model.eval()
history = messages
# response, history = model.chat(tokenizer, '查询2024年影城编码为31081501的影院全国排名', history=messages)
for response, history in model.stream_chat (tokenizer, '查询2024年影城编码为31081501的影院全国排名', history=history):
# response, history = model.chat(tokenizer, response, history=history)
    print(response)`

错误信息为:
image

Expected behavior / 期待表现

期待修复

Metadata

Metadata

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