mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
fix openai tests
This commit is contained in:
parent
fd5bbe070b
commit
11f9b47710
4 changed files with 24 additions and 6 deletions
|
|
@ -296,8 +296,12 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):
|
|||
request_data["instructions"] = instructions
|
||||
elif key == "stream_options" and isinstance(value, dict):
|
||||
request_data["stream_options"] = value.get("include_obfuscation")
|
||||
elif key == "user" and isinstance(value, str) and len(value) <= 64:
|
||||
request_data["user"] = value
|
||||
elif key == "user" and isinstance(value, str):
|
||||
# OpenAI API requires user param to be max 64 chars - truncate if longer
|
||||
if len(value) <= 64:
|
||||
request_data["user"] = value
|
||||
else:
|
||||
request_data["user"] = value[:64]
|
||||
else:
|
||||
request_data[key] = value
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ class ExceptionCheckers:
|
|||
Check if an error string indicates a context window exceeded error.
|
||||
"""
|
||||
_error_str_lowercase = error_str.lower()
|
||||
# Exclude param validation errors (e.g. OpenAI "user" param max 64 chars)
|
||||
if "string_above_max_length" in _error_str_lowercase:
|
||||
return False
|
||||
if "invalid 'user'" in _error_str_lowercase and "string too long" in _error_str_lowercase:
|
||||
return False
|
||||
known_exception_substrings = [
|
||||
"exceed context limit",
|
||||
"this model's maximum context length is",
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ async def test_openai_codex_stream(sync_mode):
|
|||
from litellm.main import stream_chunk_builder
|
||||
|
||||
kwargs = {
|
||||
"model": "openai/codex-mini-latest",
|
||||
"model": "openai/gpt-5-codex-mini",
|
||||
"messages": [{"role": "user", "content": "Hey!"}],
|
||||
"stream": True,
|
||||
}
|
||||
|
|
@ -549,16 +549,16 @@ async def test_openai_codex(sync_mode):
|
|||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "openai-codex-mini-latest",
|
||||
"model_name": "openai-gpt-5-codex-mini",
|
||||
"litellm_params": {
|
||||
"model": "openai/codex-mini-latest",
|
||||
"model": "openai/gpt-5-codex-mini",
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
kwargs = {
|
||||
"model": "openai-codex-mini-latest",
|
||||
"model": "openai-gpt-5-codex-mini",
|
||||
"messages": [{"role": "user", "content": "Hey!"}],
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,15 @@ context_window_test_cases = [
|
|||
("Rate limit reached for requests.", False),
|
||||
("The context is large, but acceptable.", False),
|
||||
("", False), # Empty string
|
||||
# OpenAI user param length validation - not a context window error
|
||||
(
|
||||
"Invalid 'user': string too long. Expected a string with maximum length 64, but got a string with length 123 instead.",
|
||||
False,
|
||||
),
|
||||
(
|
||||
'{"error": {"message": "Invalid \'user\': string too long.", "code": "string_above_max_length"}}',
|
||||
False,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue