diff --git a/api/core/file/file_manager.py b/api/core/file/file_manager.py index eb260a8f84..0b34349ba5 100644 --- a/api/core/file/file_manager.py +++ b/api/core/file/file_manager.py @@ -74,6 +74,8 @@ def to_prompt_message_content( data = _to_url(f) else: data = _to_base64_data_string(f) + if f.extension is None: + raise ValueError("Missing file extension") return VideoPromptMessageContent(data=data, format=f.extension.lstrip(".")) case _: raise ValueError("file type f.type is not supported") diff --git a/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py b/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py index 6ec219aa8d..36c3042ff6 100644 --- a/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py +++ b/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py @@ -248,6 +248,7 @@ def test_fetch_prompt_messages__vison_disabled(faker, llm_node, model_config): def test_fetch_prompt_messages__basic(faker, llm_node, model_config): # Setup dify config dify_config.MULTIMODAL_SEND_IMAGE_FORMAT = "url" + dify_config.MULTIMODAL_SEND_VIDEO_FORMAT = "url" # Generate fake values for prompt template fake_assistant_prompt = faker.sentence() @@ -443,9 +444,10 @@ def test_fetch_prompt_messages__basic(faker, llm_node, model_config): "input.image": File( tenant_id="test", type=FileType.VIDEO, - filename="test1.jpg", + filename="test1.mp4", transfer_method=FileTransferMethod.REMOTE_URL, remote_url=fake_remote_url, + extension="mp4", ) }, ),