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
d00ce29d
Unverified
Commit
d00ce29d
authored
Oct 23, 2025
by
Chauncey
Committed by
GitHub
Oct 23, 2025
Browse files
[CI] Reorganize entrypoints tests (#27403)
Signed-off-by:
chaunceyjiang
<
chaunceyjiang@gmail.com
>
parent
3b7bdf98
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
139 deletions
+141
-139
tests/entrypoints/openai/test_chat.py
tests/entrypoints/openai/test_chat.py
+0
-139
tests/entrypoints/openai/test_completion_with_function_calling.py
...trypoints/openai/test_completion_with_function_calling.py
+141
-0
No files found.
tests/entrypoints/openai/test_chat.py
View file @
d00ce29d
...
...
@@ -599,145 +599,6 @@ async def test_structured_outputs_choice_chat_logprobs(
assert
item
.
logprob
>=
-
9999.0
,
f
"Failed (top_logprobs=
{
top_logprobs
}
)"
@
pytest
.
mark
.
asyncio
async
def
test_named_tool_use
(
client
:
openai
.
AsyncOpenAI
,
sample_json_schema
,
):
messages
=
[
{
"role"
:
"system"
,
"content"
:
"you are a helpful assistant"
},
{
"role"
:
"user"
,
"content"
:
(
"Give an example JSON for an employee profile using the specified tool."
),
},
]
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
]
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
}}
# non-streaming
chat_completion
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
tools
,
tool_choice
=
tool_choice
,
)
message
=
chat_completion
.
choices
[
0
].
message
assert
len
(
message
.
content
)
==
0
json_string
=
message
.
tool_calls
[
0
].
function
.
arguments
json1
=
json
.
loads
(
json_string
)
jsonschema
.
validate
(
instance
=
json1
,
schema
=
sample_json_schema
)
messages
.
append
({
"role"
:
"assistant"
,
"content"
:
json_string
})
messages
.
append
(
{
"role"
:
"user"
,
"content"
:
"Give me another one with a different name and age"
}
)
# streaming
stream
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
tools
,
tool_choice
=
tool_choice
,
stream
=
True
,
)
output
=
[]
finish_reason_count
=
0
async
for
chunk
in
stream
:
delta
=
chunk
.
choices
[
0
].
delta
if
delta
.
role
:
assert
delta
.
role
==
"assistant"
assert
delta
.
content
is
None
or
len
(
delta
.
content
)
==
0
if
delta
.
tool_calls
:
output
.
append
(
delta
.
tool_calls
[
0
].
function
.
arguments
)
if
chunk
.
choices
[
0
].
finish_reason
is
not
None
:
finish_reason_count
+=
1
# finish reason should only return in last block
assert
finish_reason_count
==
1
json2
=
json
.
loads
(
""
.
join
(
output
))
jsonschema
.
validate
(
instance
=
json2
,
schema
=
sample_json_schema
)
assert
json1
[
"name"
]
!=
json2
[
"name"
]
assert
json1
[
"age"
]
!=
json2
[
"age"
]
@
pytest
.
mark
.
asyncio
async
def
test_inconsistent_tool_choice_and_tools
(
client
:
openai
.
AsyncOpenAI
,
sample_json_schema
):
messages
=
[
{
"role"
:
"system"
,
"content"
:
"you are a helpful assistant"
},
{
"role"
:
"user"
,
"content"
:
f
"Give an example JSON for an employee profile that "
f
"fits this schema:
{
sample_json_schema
}
"
,
},
]
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
},
},
)
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
],
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"nondefined_function_name"
},
},
)
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
],
tool_choice
=
{},
)
@
pytest
.
mark
.
asyncio
async
def
test_response_format_json_object
(
client
:
openai
.
AsyncOpenAI
):
for
_
in
range
(
2
):
...
...
tests/entrypoints/openai/test_completion_with_function_calling.py
View file @
d00ce29d
...
...
@@ -2,7 +2,9 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
datetime
import
json
import
jsonschema
import
openai
# use the official client for correctness check
import
pytest
import
pytest_asyncio
...
...
@@ -341,3 +343,142 @@ async def test_no_args_tool_call(
else
:
# No tool called — just print model's direct reply
assert
message
.
content
is
not
None
@
pytest
.
mark
.
asyncio
async
def
test_named_tool_use
(
client
:
openai
.
AsyncOpenAI
,
sample_json_schema
,
):
messages
=
[
{
"role"
:
"system"
,
"content"
:
"you are a helpful assistant"
},
{
"role"
:
"user"
,
"content"
:
(
"Give an example JSON for an employee profile using the specified tool."
),
},
]
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
]
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
}}
# non-streaming
chat_completion
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
tools
,
tool_choice
=
tool_choice
,
)
message
=
chat_completion
.
choices
[
0
].
message
assert
len
(
message
.
content
)
==
0
json_string
=
message
.
tool_calls
[
0
].
function
.
arguments
json1
=
json
.
loads
(
json_string
)
jsonschema
.
validate
(
instance
=
json1
,
schema
=
sample_json_schema
)
messages
.
append
({
"role"
:
"assistant"
,
"content"
:
json_string
})
messages
.
append
(
{
"role"
:
"user"
,
"content"
:
"Give me another one with a different name and age"
}
)
# streaming
stream
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
tools
,
tool_choice
=
tool_choice
,
stream
=
True
,
)
output
=
[]
finish_reason_count
=
0
async
for
chunk
in
stream
:
delta
=
chunk
.
choices
[
0
].
delta
if
delta
.
role
:
assert
delta
.
role
==
"assistant"
assert
delta
.
content
is
None
or
len
(
delta
.
content
)
==
0
if
delta
.
tool_calls
:
output
.
append
(
delta
.
tool_calls
[
0
].
function
.
arguments
)
if
chunk
.
choices
[
0
].
finish_reason
is
not
None
:
finish_reason_count
+=
1
# finish reason should only return in last block
assert
finish_reason_count
==
1
json2
=
json
.
loads
(
""
.
join
(
output
))
jsonschema
.
validate
(
instance
=
json2
,
schema
=
sample_json_schema
)
assert
json1
[
"name"
]
!=
json2
[
"name"
]
assert
json1
[
"age"
]
!=
json2
[
"age"
]
@
pytest
.
mark
.
asyncio
async
def
test_inconsistent_tool_choice_and_tools
(
client
:
openai
.
AsyncOpenAI
,
sample_json_schema
):
messages
=
[
{
"role"
:
"system"
,
"content"
:
"you are a helpful assistant"
},
{
"role"
:
"user"
,
"content"
:
f
"Give an example JSON for an employee profile that "
f
"fits this schema:
{
sample_json_schema
}
"
,
},
]
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
},
},
)
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
],
tool_choice
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"nondefined_function_name"
},
},
)
with
pytest
.
raises
(
openai
.
BadRequestError
):
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
max_completion_tokens
=
1000
,
tools
=
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"dummy_function_name"
,
"description"
:
"This is a dummy function"
,
"parameters"
:
sample_json_schema
,
},
}
],
tool_choice
=
{},
)
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