Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
b6af24fb
Unverified
Commit
b6af24fb
authored
Aug 13, 2025
by
Will Eaton
Committed by
GitHub
Aug 13, 2025
Browse files
[CI][Entrypoints]: add filter to generation to filter out invalid tool calls (#22826)
Signed-off-by:
Will Eaton
<
weaton@redhat.com
>
parent
0ca2393b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
tests/entrypoints/openai/test_openai_schema.py
tests/entrypoints/openai/test_openai_schema.py
+32
-16
No files found.
tests/entrypoints/openai/test_openai_schema.py
View file @
b6af24fb
...
...
@@ -54,38 +54,54 @@ def before_generate_case(context: schemathesis.hooks.HookContext, strategy):
op
=
context
.
operation
assert
op
is
not
None
def
no_
file
_type
(
case
:
schemathesis
.
models
.
Case
):
def
no_
invalid
_type
s
(
case
:
schemathesis
.
models
.
Case
):
"""
This filter skips test cases for the `POST /tokenize` endpoint where the
HTTP request body uses `"type": "file"` in any message's content.
We expect these cases to fail because that type isn't implemented here
https://github.com/vllm-project/vllm/blob/0b34593017953051b3225b1483ce0f4670e3eb0e/vllm/entrypoints/chat_utils.py#L1038-L1095
This filter skips test cases with invalid data that schemathesis
incorrectly generates due to permissive schema configurations.
1. Skips `POST /tokenize` endpoint cases with `"type": "file"` in
message content, which isn't implemented.
2. Skips tool_calls with `"type": "custom"` which schemathesis
incorrectly generates instead of the valid `"type": "function"`.
Example test cases that are skipped:
curl -X POST -H 'Content-Type: application/json'
\
-d '{"messages": [
{"role": "assistant"},
{"content": [{"file": {}, "type": "file"}], "role": "user"}]}'
\
-d '{"messages": [{"content": [{"file": {}, "type": "file"}], "role": "user"}]}'
\
http://localhost:8000/tokenize
curl -X POST -H 'Content-Type: application/json'
\
-d '{"messages": [{"
content": [{"fil
e":
{
}, "
type": "file"}], "rol
e": "us
er"
}]}'
\
http://localhost:8000/
tokenize
-d '{"messages": [{"
role": "assistant", "tool_calls": [{"custom": {"input": "", "nam
e":
""
}, "
id": "", "typ
e": "
c
us
tom"}]
}]}'
\
http://localhost:8000/
v1/chat/completions
"""
# noqa: E501
if
(
op
.
method
.
lower
()
==
"post"
and
op
.
path
==
"/tokenize"
and
hasattr
(
case
,
"body"
)
and
isinstance
(
case
.
body
,
dict
)
if
(
hasattr
(
case
,
"body"
)
and
isinstance
(
case
.
body
,
dict
)
and
"messages"
in
case
.
body
and
isinstance
(
case
.
body
[
"messages"
],
list
)
and
len
(
case
.
body
[
"messages"
])
>
0
):
for
message
in
case
.
body
[
"messages"
]:
if
not
isinstance
(
message
,
dict
):
continue
content
=
message
.
get
(
"content"
,
[])
if
not
isinstance
(
content
,
list
)
or
len
(
content
)
==
0
:
continue
if
any
(
item
.
get
(
"type"
)
==
"file"
for
item
in
content
):
return
False
# Check for invalid file type in tokenize endpoint
if
op
.
method
.
lower
()
==
"post"
and
op
.
path
==
"/tokenize"
:
content
=
message
.
get
(
"content"
,
[])
if
(
isinstance
(
content
,
list
)
and
len
(
content
)
>
0
and
any
(
item
.
get
(
"type"
)
==
"file"
for
item
in
content
)):
return
False
# Check for invalid tool_calls with non-function types
tool_calls
=
message
.
get
(
"tool_calls"
,
[])
if
isinstance
(
tool_calls
,
list
):
for
tool_call
in
tool_calls
:
if
isinstance
(
tool_call
,
dict
):
if
tool_call
.
get
(
"type"
)
!=
"function"
:
return
False
if
"custom"
in
tool_call
:
return
False
return
True
return
strategy
.
filter
(
no_
file
_type
)
return
strategy
.
filter
(
no_
invalid
_type
s
)
@
schema
.
parametrize
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment