mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
test: add sync and async custom_llm_provider bridge propagation tests
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
b2ae0151e7
commit
d086f8574d
1 changed files with 52 additions and 0 deletions
|
|
@ -40,6 +40,58 @@ def _bedrock_mantle_kwargs() -> dict:
|
|||
}
|
||||
|
||||
|
||||
def _openai_kwargs() -> dict:
|
||||
messages = [{"role": "user", "content": "hi"}]
|
||||
logging_obj = LiteLLMLogging(
|
||||
litellm_call_id="test-call",
|
||||
call_type="completion",
|
||||
model="gpt-5.5",
|
||||
messages=messages,
|
||||
function_id="fn-id",
|
||||
stream=False,
|
||||
start_time=datetime.now(),
|
||||
)
|
||||
return {
|
||||
"model": "gpt-5.5",
|
||||
"custom_llm_provider": "openai",
|
||||
"messages": messages,
|
||||
"optional_params": {},
|
||||
"litellm_params": {},
|
||||
"headers": {},
|
||||
"model_response": ModelResponse(),
|
||||
"logging_obj": logging_obj,
|
||||
}
|
||||
|
||||
|
||||
def test_completion_forwards_custom_llm_provider_to_responses():
|
||||
bridge = ResponsesToCompletionBridgeHandler()
|
||||
cached = ModelResponse(id="chatcmpl-cached", model="gpt-5.5")
|
||||
|
||||
with patch("litellm.responses", return_value=cached) as fake_responses:
|
||||
result = bridge.completion(**_openai_kwargs())
|
||||
|
||||
assert result is cached
|
||||
assert fake_responses.call_args.kwargs["custom_llm_provider"] == "openai"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acompletion_forwards_custom_llm_provider_to_aresponses():
|
||||
bridge = ResponsesToCompletionBridgeHandler()
|
||||
cached = ModelResponse(id="chatcmpl-cached", model="gpt-5.5")
|
||||
|
||||
async def _fake_aresponses(**kwargs):
|
||||
_fake_aresponses.kwargs = kwargs
|
||||
return cached
|
||||
|
||||
_fake_aresponses.kwargs = {}
|
||||
|
||||
with patch("litellm.aresponses", _fake_aresponses):
|
||||
result = await bridge.acompletion(**_openai_kwargs())
|
||||
|
||||
assert result is cached
|
||||
assert _fake_aresponses.kwargs["custom_llm_provider"] == "openai"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acompletion_forwards_aws_region_name_to_aresponses():
|
||||
bridge = ResponsesToCompletionBridgeHandler()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue