Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Hdandria <henri.dandria@mistral.ai>
Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai>
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Mert Unsal <mert.unsal@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Clément Drouin 2026-06-19 11:01:24 +02:00 committed by GitHub
parent 564a14365e
commit 6bedf271ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
223 changed files with 10533 additions and 6947 deletions

View file

@ -4,27 +4,43 @@ from pathlib import Path
import pytest
from vibe.core.types import ImageAttachment, LLMMessage, Role
from vibe.core.types import (
FileImageSource,
ImageAttachment,
LLMMessage,
Role,
UserDisplayContentMetadata,
)
@pytest.fixture()
def image_a(tmp_path: Path) -> ImageAttachment:
p = tmp_path / "a.png"
p.write_bytes(b"\x89PNG")
return ImageAttachment(path=p, alias="a.png", mime_type="image/png")
return ImageAttachment(
source=FileImageSource(path=p), alias="a.png", mime_type="image/png"
)
@pytest.fixture()
def image_b(tmp_path: Path) -> ImageAttachment:
p = tmp_path / "b.png"
p.write_bytes(b"\x89PNG")
return ImageAttachment(path=p, alias="b.png", mime_type="image/png")
return ImageAttachment(
source=FileImageSource(path=p), alias="b.png", mime_type="image/png"
)
def _msg(content: str, images: list[ImageAttachment] | None = None) -> LLMMessage:
return LLMMessage(role=Role.assistant, content=content, images=images)
def _display_content(host: str) -> UserDisplayContentMetadata:
return UserDisplayContentMetadata(
version="1.0.0", host=host, content=[{"type": "text", "text": host}]
)
def test_merge_prefers_self_images_when_present(
image_a: ImageAttachment, image_b: ImageAttachment
) -> None:
@ -49,3 +65,26 @@ def test_merge_preserves_explicit_empty_self_images_over_other(
def test_merge_yields_none_when_both_sides_are_none() -> None:
merged = _msg("hi") + _msg(" there")
assert merged.images is None
def test_merge_prefers_self_user_display_content_when_present() -> None:
self_display_content = _display_content("mistral-vscode")
other_display_content = _display_content("mistral-jetbrains")
merged = LLMMessage(
role=Role.user, content="hi", user_display_content=self_display_content
) + LLMMessage(
role=Role.user, content=" there", user_display_content=other_display_content
)
assert merged.user_display_content == self_display_content
def test_merge_falls_back_to_other_user_display_content() -> None:
other_display_content = _display_content("mistral-vscode")
merged = LLMMessage(role=Role.user, content="hi") + LLMMessage(
role=Role.user, content=" there", user_display_content=other_display_content
)
assert merged.user_display_content == other_display_content