mirror of
https://github.com/NVIDIA-NeMo/DataDesigner
synced 2026-05-24 09:48:29 +00:00
Preserves tree from previous docs-website head: 5e47d33ea8. This branch is a CI-managed publish artifact like gh-pages; source provenance is tracked in commit messages rather than Git ancestry.
23 lines
1.1 KiB
Python
23 lines
1.1 KiB
Python
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from data_designer.engine.models.utils import ChatMessage, prompt_to_messages
|
|
|
|
|
|
def test_prompt_to_messages() -> None:
|
|
stub_system_prompt = "some system prompt"
|
|
mult_modal_context = {"type": "image_url", "image_url": {"url": "http://example.com/image.png"}}
|
|
assert prompt_to_messages(user_prompt="hello") == [ChatMessage.as_user("hello")]
|
|
assert prompt_to_messages(user_prompt="hello", system_prompt=stub_system_prompt) == [
|
|
ChatMessage.as_system(stub_system_prompt),
|
|
ChatMessage.as_user("hello"),
|
|
]
|
|
assert prompt_to_messages(user_prompt="hello", multi_modal_context=[mult_modal_context]) == [
|
|
ChatMessage.as_user([mult_modal_context, {"type": "text", "text": "hello"}])
|
|
]
|
|
assert prompt_to_messages(
|
|
user_prompt="hello", system_prompt=stub_system_prompt, multi_modal_context=[mult_modal_context]
|
|
) == [
|
|
ChatMessage.as_system(stub_system_prompt),
|
|
ChatMessage.as_user([mult_modal_context, {"type": "text", "text": "hello"}]),
|
|
]
|