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,