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
e74f156ff7
commit
9e6459cf73
2 changed files with 21 additions and 17 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
|
||||
|
|
|
|||
|
|
@ -8309,7 +8309,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",
|
||||
|
|
@ -8399,8 +8403,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),
|
||||
|
|
@ -8543,8 +8547,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