mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
test: adapt copied provider checks to release interfaces
This commit is contained in:
parent
c3ffb3d0a8
commit
07a5ec0b6f
2 changed files with 22 additions and 23 deletions
|
|
@ -57,9 +57,6 @@ _AZURE_KEY: Final = "synthetic-azure-ai-key"
|
|||
_BEDROCK_TOKEN: Final = "synthetic-bedrock-bearer"
|
||||
|
||||
|
||||
_DEPRECATED_OUTPUT_FORMAT: Final = "output_format: this field is deprecated, use output_config.format"
|
||||
|
||||
|
||||
_BAD_OUTPUT_CONFIG: Final = "output_config: Input should be a valid dictionary"
|
||||
|
||||
|
||||
|
|
@ -349,9 +346,9 @@ def _error(status: int, message: str) -> Reply:
|
|||
|
||||
|
||||
def _format_fault(body: Mapping[str, JsonValue], vertex: bool) -> str | None:
|
||||
if vertex and "output_format" in body:
|
||||
return _DEPRECATED_OUTPUT_FORMAT
|
||||
output_config: Final = body.get("output_config")
|
||||
output_config: Final = (
|
||||
{"format": body["output_format"]} if vertex and "output_format" in body else body.get("output_config")
|
||||
)
|
||||
if output_config is None:
|
||||
return None
|
||||
if not isinstance(output_config, dict):
|
||||
|
|
@ -465,9 +462,8 @@ def _json_tool_schema(delivery: _Delivery) -> dict[str, JsonValue]:
|
|||
return object_value(json_tool["input_schema"])
|
||||
|
||||
|
||||
def _folded_format(delivery: _Delivery) -> dict[str, JsonValue]:
|
||||
assert "output_format" not in delivery.body, delivery.body
|
||||
return object_value(object_value(delivery.body["output_config"])["format"])
|
||||
def _native_format(delivery: _Delivery) -> dict[str, JsonValue]:
|
||||
return object_value(delivery.body["output_format"])
|
||||
|
||||
|
||||
def _marker(shape: str) -> tuple[str, str]:
|
||||
|
|
@ -672,5 +668,5 @@ def test_vertex_chat_native_schema_keeps_min_items_one_and_closes_a_nullable_obj
|
|||
)
|
||||
assert _chat_content(response) == _payload(marker_hex), response.text
|
||||
sent: Final = _one_delivery(wire, marker_hex)
|
||||
assert _folded_format(sent) == {"type": "json_schema", "schema": expected}, sent.body
|
||||
assert _native_format(sent) == {"type": "json_schema", "schema": expected}, sent.body
|
||||
assert "tools" not in sent.body, sent.body
|
||||
|
|
|
|||
|
|
@ -6878,9 +6878,6 @@ def test_chat_dummy_tool_result_for_an_orphaned_tool_call_replays_a_byte_identic
|
|||
assert requests[0]["messages"][2]["content"][0]["type"] == "tool_result"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def test_json_mode_keeps_the_thinking_that_preceded_the_json_tool_call():
|
||||
thinking_block: Final = {"type": "thinking", "thinking": "The user wants a greeting.", "signature": "sig-1"}
|
||||
body: Final = _json_mode_message_body("tool_use", None)
|
||||
|
|
@ -6903,9 +6900,7 @@ class JsonModeMessageBody(TypedDict):
|
|||
content: ReadOnly[list[dict[str, JsonValue]]]
|
||||
|
||||
|
||||
def _json_mode_message_body(
|
||||
stop_reason: str, stop_details: dict[str, JsonValue] | None
|
||||
) -> JsonModeMessageBody:
|
||||
def _json_mode_message_body(stop_reason: str, stop_details: dict[str, JsonValue] | None) -> JsonModeMessageBody:
|
||||
return {
|
||||
"id": "msg_json_mode",
|
||||
"type": "message",
|
||||
|
|
@ -7148,7 +7143,11 @@ def _json_tool_call(arguments: object) -> list[ChatCompletionToolCallChunk]:
|
|||
),
|
||||
pytest.param(_VALUES_SCHEMA, {"values": [1, 2]}, {"values": [1, 2]}, id="values_is_a_schema_property"),
|
||||
pytest.param(
|
||||
{"type": "object", "properties": {"values": {"type": "object", "additionalProperties": {"type": "integer"}}}, "required": ["values"]},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {"values": {"type": "object", "additionalProperties": {"type": "integer"}}},
|
||||
"required": ["values"],
|
||||
},
|
||||
{"values": {}},
|
||||
{"values": {}},
|
||||
id="empty_open_values_object_is_preserved",
|
||||
|
|
@ -7238,8 +7237,8 @@ def _json_tool_call(arguments: object) -> list[ChatCompletionToolCallChunk]:
|
|||
],
|
||||
)
|
||||
def test_convert_tool_response_to_message_unwraps_only_an_unambiguous_schema_envelope(
|
||||
schema: dict, tool_input: dict, expected_content: dict
|
||||
):
|
||||
schema: dict[str, object], tool_input: dict[str, JsonValue], expected_content: dict[str, JsonValue]
|
||||
) -> None:
|
||||
message = AnthropicConfig._convert_tool_response_to_message(
|
||||
tool_calls=_json_tool_call(tool_input),
|
||||
response_format_schema=_schema(schema),
|
||||
|
|
@ -7382,8 +7381,12 @@ def test_vertex_claude_tool_emulated_response_format_returns_the_object_the_mode
|
|||
|
||||
|
||||
def test_json_tool_without_arguments_has_no_message() -> None:
|
||||
calls: Final = [ChatCompletionToolCallChunk(
|
||||
id="toolu_empty", type="function", index=0,
|
||||
function=ChatCompletionToolCallFunctionChunk(name=RESPONSE_FORMAT_TOOL_NAME),
|
||||
)]
|
||||
calls: Final = [
|
||||
ChatCompletionToolCallChunk(
|
||||
id="toolu_empty",
|
||||
type="function",
|
||||
index=0,
|
||||
function=ChatCompletionToolCallFunctionChunk(name=RESPONSE_FORMAT_TOOL_NAME),
|
||||
)
|
||||
]
|
||||
assert AnthropicConfig._convert_tool_response_to_message(calls, _schema(_RISK_SCHEMA)) is None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue