Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
aliang-123 opened this issue Jan 15, 2025 · 0 comments
Open
1 of 2 tasks

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

aliang-123 opened this issue Jan 15, 2025 · 0 comments

Comments

@aliang-123
Copy link

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 / 期待表现

期待修复

@aliang-123 aliang-123 changed the title 使用流式输出调用工具是返回异常 使用流式输出stream_chat调用工具时返回异常 Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant