litellm/tests/integration/translation/templates/azure.py
Kerry Lu 7b7604f0ed
test(translation): share rich fixtures across Claude, GPT and Gemini providers (#46585)
* test(integration): add rich anthropic claude haiku 5.5, opus 5.5 and fable 5.1 translation cases

Capture-backed basic cases on /v1/chat/completions, /v1/messages and /v1/responses for claude-haiku-5-5, claude-opus-5-5 and claude-fable-5-1, reusing the shared client templates and ANTHROPIC_MESSAGES_REQUEST/RESPONSE with model-specific id, content and usage overrides. The minimal Opus 5.5 hello cases are replaced by the rich conversation. Sonnet 5.5 and legacy models are unchanged

* test(translation): rich OpenAI captures for gpt-6.1-sol, gpt-6-luna, gpt-6-astra and gpt-5.6-terra

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(translation): rich Azure gpt-6.1-sol, gpt-6-luna, gpt-6-astra and gpt-5.6-terra cases

* test(translation): rich azure_ai Claude cases for haiku-5-5 and fable-5-1

Bind the shared chat_completions, messages and responses client templates and the anthropic provider templates to azure_ai/claude-haiku-5-5 and azure_ai/claude-fable-5-1 from real Azure AI Foundry captures, keeping the Azure dialect exact (/anthropic/v1/messages, x-api-key plus api-key on chat_completions and responses, system as a text block list on /v1/messages). Add prompt_cache_hit variants for both models from the second call inside the cache window. The two deployments need rows in tests/integration/proxy_config.yaml

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(translation): rich Gemini bases for gemini-3.8-flash, gemini-3.1-pro-preview and gemini-4-argon

Add the shared generateContent provider templates in templates/gemini.py from
real captures and bind the three target models on chat completions, messages
and responses with explicit per-model response overrides. gemini-4-argon is
registered in the three basic lists. gemini-3.5-flash is unchanged

* test(translation): enrich vertex_ai claude and gemini cases from live captures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(integration): rich Bedrock converse, invoke and mantle translation cases from real captures

* test(integration): register the rich translation deployments and follow the rich Gemini 3.8 Flash cases

Add the synthetic deployments the rich provider cases bind (anthropic, openai, azure, azure_ai, gemini, vertex_ai, bedrock converse, invoke and mantle) to tests/integration/proxy_config.yaml, all pointed at the fake provider on 127.0.0.1:8191 with synthetic keys. The Gemini omitted-temperature contract now takes its expected generationConfig and reply text from the rich GEMINI_3_8_FLASH_TEST_CASE literals instead of the retired minimal hello cases

* test(translation): reuse bridged and native response templates

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: kerry <kerry@berri.ai>
2026-10-14 19:53:09 -07:00

354 lines
14 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from collections.abc import Mapping
from typing import Final
from pydantic import JsonValue
AZURE_RESPONSES_REQUEST: Final[Mapping[str, JsonValue]] = {
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": ("The checkout rejects quantities of zero. Find the validation code and its tests."),
}
],
},
{
"role": "assistant",
"content": [{"type": "output_text", "text": "I will locate the quantity validation and its tests."}],
},
{
"type": "function_call",
"call_id": "toolu_synthetic_search_01",
"name": "search_files",
"arguments": '{"query": "quantity", "paths": ["shop/", "tests/"]}',
},
{
"type": "function_call_output",
"call_id": "toolu_synthetic_search_01",
"output": (
'{"matches": [{"path": "shop/validation.py", "line": 18, "text": "def '
'validate_quantity(quantity):"}, {"path": "tests/test_validation.py", "line": 7, '
'"text": "def test_zero_quantity():"}]}'
),
},
{
"role": "user",
"content": [
{
"type": "input_text",
"text": (
"Read the validation file first so we can understand how zero and negative "
"quantities are handled."
),
}
],
},
],
"instructions": (
"You help maintain a synthetic Python project. Read the relevant files before "
"suggesting a fix. Explain which file you need next, then call a read-only tool. "
"Never change files. Use the responses client for this project review. Consider "
"zero, negative and non-integer quantities before choosing the next file to "
"inspect."
),
"max_output_tokens": 1024,
"reasoning": {"effort": "high"},
"tools": [
{
"type": "function",
"name": "search_files",
"description": "Search source and test files for a literal term.",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}, "paths": {"type": "array", "items": {"type": "string"}}},
"required": ["query", "paths"],
"additionalProperties": False,
},
},
{
"type": "function",
"name": "read_file",
"description": "Read a range of lines from a project file.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"start_line": {"type": "integer", "minimum": 1},
"end_line": {"type": "integer", "minimum": 1},
},
"required": ["path", "start_line", "end_line"],
"additionalProperties": False,
},
},
],
}
AZURE_RESPONSES_BRIDGE_REQUEST: Final[Mapping[str, JsonValue]] = {
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": ("The checkout rejects quantities of zero. Find the validation code and its tests."),
}
],
},
{
"type": "message",
"role": "assistant",
"content": [{"type": "output_text", "text": "I will locate the quantity validation and its tests."}],
},
{
"type": "function_call",
"call_id": "toolu_synthetic_search_01",
"name": "search_files",
"arguments": '{"query": "quantity", "paths": ["shop/", "tests/"]}',
},
{
"type": "function_call_output",
"call_id": "toolu_synthetic_search_01",
"output": [
{
"type": "input_text",
"text": (
'{"matches": [{"path": "shop/validation.py", "line": 18, "text": "def '
'validate_quantity(quantity):"}, {"path": "tests/test_validation.py", "line": 7, '
'"text": "def test_zero_quantity():"}]}'
),
}
],
},
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": (
"Read the validation file first so we can understand how zero and negative "
"quantities are handled."
),
}
],
},
],
"instructions": (
"You help maintain a synthetic Python project. Read the relevant files before "
"suggesting a fix. Explain which file you need next, then call a read-only tool. "
"Never change files. Use the chat_completions client for this project review. "
"Consider zero, negative and non-integer quantities before choosing the next file "
"to inspect."
),
"max_output_tokens": 1024,
"reasoning": {"effort": "high"},
"tools": [
{
"name": "search_files",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}, "paths": {"type": "array", "items": {"type": "string"}}},
"required": ["query", "paths"],
"additionalProperties": False,
},
"strict": None,
"type": "function",
"description": "Search source and test files for a literal term.",
},
{
"name": "read_file",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"start_line": {"type": "integer", "minimum": 1},
"end_line": {"type": "integer", "minimum": 1},
},
"required": ["path", "start_line", "end_line"],
"additionalProperties": False,
},
"strict": None,
"type": "function",
"description": "Read a range of lines from a project file.",
},
],
}
AZURE_RESPONSES_RESPONSE: Final[Mapping[str, JsonValue]] = {
"id": "resp_03952e888f4f1827006ad023aa00108190b24e51d376e9a373",
"object": "response",
"created_at": 1792025514,
"status": "completed",
"background": False,
"completed_at": 1792025519,
"content_filters": [
{
"blocked": False,
"source_type": "prompt",
"content_filter_raw": [],
"content_filter_results": {
"hate": {"filtered": False, "severity": "safe"},
"sexual": {"filtered": False, "severity": "safe"},
"violence": {"filtered": False, "severity": "safe"},
"self_harm": {"filtered": False, "severity": "safe"},
"jailbreak": {"detected": False, "filtered": False},
},
"content_filter_offsets": {"start_offset": 0, "end_offset": 575, "check_offset": 0},
},
{
"blocked": False,
"source_type": "completion",
"content_filter_raw": [],
"content_filter_results": {
"protected_material_code": {"detected": False, "filtered": False},
"protected_material_text": {"detected": False, "filtered": False},
"hate": {"filtered": False, "severity": "safe"},
"sexual": {"filtered": False, "severity": "safe"},
"violence": {"filtered": False, "severity": "safe"},
"self_harm": {"filtered": False, "severity": "safe"},
},
"content_filter_offsets": {"start_offset": 0, "end_offset": 578, "check_offset": 0},
},
],
"error": None,
"frequency_penalty": 0.0,
"incomplete_details": None,
"instructions": (
"You help maintain a synthetic Python project. Read the relevant files before "
"suggesting a fix. Explain which file you need next, then call a read-only tool. "
"Never change files. Use the chat_completions client for this project review. "
"Consider zero, negative and non-integer quantities before choosing the next file "
"to inspect."
),
"max_output_tokens": 1024,
"max_tool_calls": None,
"model": "gpt-6.1-sol",
"moderation": None,
"output": [
{
"id": "rs_03952e888f4f1827006ad023ae0c048190acdee29b5d20c5b3",
"type": "reasoning",
"content": [],
"encrypted_content": (
"gAAAAABq0COvgomuqwo0Z3KFAStLOih2JmYOubPtUjtpD1zCRSCXdDnHGkj8asyVemaCsQr8szo_esDZ"
"PIT2Y9gh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"
"YOXw0jgw-Ze8EmKLDZoCz3jq4NjNA9s0sLGd_Xg0kR6GeOmpLMWtT024yQ7gowGendkcHjIw3S-fIfiI"
"zJtZ-Hk9_iMBk8FE5Syb-j0kmzGF2gFj7ywTTdGoMsM3aTOvusVL14D1N_IfMryUdeoNJ41G8SvqGjtH"
"gyqCER9grGItYgKueDjt6IC5I086__HogkmrpzLZxSIpFCXX6rArVDsIYdS9XFgLW1oBKsVUs5DLnIYe"
"Ncv_cC-oTvEDBaYdhDPYbn_5N6q0q7dtbvohO-XJxOfLh0jC3TelEn7m5EXMPpAygQP2sPtI4_SmhA1C"
"Tji-B-6J60kBUiKmp65ZVxx8BDMI9dv3PLxsw4R0zh6fP_Fsok0UKJOQlfC6k47yhDuTcdN_vq7sAc3q"
"6P9b7Ud7Bz3JtY8Lg516vLK2vti4iwu7dcHlNiIoNZTGMANKYccO-XSRuJbX09bypgJB9sSR56_-Cb1i"
"b1C5RtkTv3ueRvq58Hw1RIINmiTTJn2MiYi_P-yXAirR39YTxcyRNUk4UDgK1lK73lrnpiBELJe-CPQg"
"wgLlalzjk8j0CnIMUA=="
),
"summary": [],
},
{
"id": "msg_03952e888f4f1827006ad023ae6e608190afabb95cbcebf3c9",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": [],
"logprobs": [],
"text": (
"I’ll read `shop/validation.py` first to check how it handles zero, negative, and "
"non-integer quantities.\n"
),
}
],
"phase": "commentary",
"role": "assistant",
},
{
"id": "fc_03952e888f4f1827006ad023aeb68881909fd9d88d37ef120a",
"type": "function_call",
"status": "completed",
"arguments": '{"path":"shop/validation.py","start_line":1,"end_line":200}',
"call_id": "call_mWfqifVeCXVWLiiNM1Ac2MjL",
"name": "read_file",
},
],
"parallel_tool_calls": True,
"presence_penalty": 0.0,
"previous_response_id": None,
"prompt_cache_key": None,
"prompt_cache_retention": "24h",
"reasoning": {"context": "all_turns", "effort": "high", "mode": "standard", "summary": None},
"safety_identifier": None,
"service_tier": "default",
"store": True,
"temperature": 1.0,
"text": {"format": {"type": "text"}, "verbosity": "medium"},
"tool_choice": "auto",
"tool_usage": {
"image_gen": {
"input_tokens": 0,
"input_tokens_details": {"image_tokens": 0, "text_tokens": 0},
"output_tokens": 0,
"output_tokens_details": {"image_tokens": 0, "text_tokens": 0},
"total_tokens": 0,
},
"web_search": {"num_requests": 0},
},
"tools": [
{
"type": "function",
"description": "Search source and test files for a literal term.",
"name": "search_files",
"output_schema": None,
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}, "paths": {"type": "array", "items": {"type": "string"}}},
"required": ["query", "paths"],
"additionalProperties": False,
},
"strict": False,
},
{
"type": "function",
"description": "Read a range of lines from a project file.",
"name": "read_file",
"output_schema": None,
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"start_line": {"type": "integer", "minimum": 1},
"end_line": {"type": "integer", "minimum": 1},
},
"required": ["path", "start_line", "end_line"],
"additionalProperties": False,
},
"strict": False,
},
],
"top_logprobs": 0,
"top_p": 0.98,
"truncation": "disabled",
"usage": {
"input_tokens": 312,
"input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0},
"output_tokens": 154,
"output_tokens_details": {"reasoning_tokens": 89},
"total_tokens": 466,
},
"user": None,
"metadata": {},
}