test(vertex-ai): cover preserved native content variants

This commit is contained in:
Devin AI 2026-07-10 07:17:23 +00:00
parent 103b3a9b81
commit 0d847c8149
2 changed files with 5 additions and 1 deletions

View file

@ -84,7 +84,9 @@ class VertexAIGoogleGenAIConfig(GoogleGenAIConfig):
vertex_contents = (
[
{**content, "role": content.get("role", "user")} if isinstance(content, dict) else content
({**content, "role": "user"} if "role" not in content else content)
if isinstance(content, dict)
else content
for content in contents
]
if isinstance(contents, list)

View file

@ -8,6 +8,7 @@ def test_transform_generate_content_request_defaults_omitted_role():
contents = [
{"parts": [{"text": "Hello"}]},
{"role": "model", "parts": [{"text": "Hi"}]},
"Raw content",
]
result = config.transform_generate_content_request(
@ -20,5 +21,6 @@ def test_transform_generate_content_request_defaults_omitted_role():
assert result["contents"] == [
{"role": "user", "parts": [{"text": "Hello"}]},
{"role": "model", "parts": [{"text": "Hi"}]},
"Raw content",
]
assert "role" not in contents[0]