From 604f4005c9397cc51c27a5de5fe388b700f9162e Mon Sep 17 00:00:00 2001 From: hiyouga <467089858@qq.com> Date: Sat, 2 Nov 2024 21:04:18 +0800 Subject: [PATCH] fix webchat Former-commit-id: ba10d54bf93c54ab8f691ea53bff850e3595a1a6 --- src/llamafactory/api/chat.py | 3 +-- src/llamafactory/webui/chatter.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/llamafactory/api/chat.py b/src/llamafactory/api/chat.py index 97326e43..05db57a7 100644 --- a/src/llamafactory/api/chat.py +++ b/src/llamafactory/api/chat.py @@ -115,7 +115,6 @@ def _process_request( else: input_messages.append({"role": ROLE_MAPPING[message.role], "content": message.content}) - images = None if len(images) == 0 else images tool_list = request.tools if isinstance(tool_list, list) and len(tool_list): try: @@ -125,7 +124,7 @@ def _process_request( else: tools = None - return input_messages, system, tools, images + return input_messages, system, tools, images or None def _create_stream_chat_completion_chunk( diff --git a/src/llamafactory/webui/chatter.py b/src/llamafactory/webui/chatter.py index 78ef3efc..1934a1a7 100644 --- a/src/llamafactory/webui/chatter.py +++ b/src/llamafactory/webui/chatter.py @@ -144,8 +144,8 @@ class WebChatModel(ChatModel): messages, system, tools, - images=[image], - videos=[video], + images=[image] if image else None, + videos=[video] if video else None, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature,