Skip to content

api_demo 使用问题:使用工具时Chatmessage的格式问题 #3077

Closed
@Lealand23231513

Description

Reminder

  • I have read the README and searched the existing issues.

Reproduction

在ChatMessage中content被设定为str,而在ChatCompletionMessage中content可以为None。
98a7604a4fd4f7d4593beff9358e2da

如果使用api demo,并且需要模型使用工具,那么由于: src/llmtuner/api/app.py 中的 create_chat_completion函数中的
1930ab121856e6b05bae1936b8c4b35
使用ChatCompletionMessage的content缺省值,会导致错误:

openai.UnprocessableEntityError: Error code: 422 - {'detail': [{'type': 'string_type', 'loc': ['body', 'messages', 2, 'content'], 'msg': 'Input should be a valid string', 'input': None, 'url': 'https://errors.pydantic.dev/2.6/v/string_type'}]}

Expected behavior

No response

System Info

No response

Others

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    solvedThis problem has been already solved

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions