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
9ae3c55b
Unverified
Commit
9ae3c55b
authored
Dec 04, 2025
by
Yu Jiaqi
Committed by
GitHub
Dec 03, 2025
Browse files
SigLIP example add chat_template (#29902)
Signed-off-by:
piood
<
2477084691@qq.com
>
parent
9bcf9229
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
examples/pooling/embed/openai_chat_embedding_client_for_multimodal.py
...ling/embed/openai_chat_embedding_client_for_multimodal.py
+2
-1
vllm/entrypoints/chat_utils.py
vllm/entrypoints/chat_utils.py
+27
-8
No files found.
examples/pooling/embed/openai_chat_embedding_client_for_multimodal.py
View file @
9ae3c55b
...
@@ -150,7 +150,8 @@ def run_siglip(client: OpenAI, model: str):
...
@@ -150,7 +150,8 @@ def run_siglip(client: OpenAI, model: str):
Start the server using:
Start the server using:
vllm serve google/siglip-base-patch16-224
\
vllm serve google/siglip-base-patch16-224
\
--runner pooling
--runner pooling
\
--chat-template template_basic.jinja
"""
"""
response
=
create_chat_embeddings
(
response
=
create_chat_embeddings
(
...
...
vllm/entrypoints/chat_utils.py
View file @
9ae3c55b
...
@@ -1139,11 +1139,19 @@ def validate_chat_template(chat_template: Path | str | None):
...
@@ -1139,11 +1139,19 @@ def validate_chat_template(chat_template: Path | str | None):
not
any
(
c
in
chat_template
for
c
in
JINJA_CHARS
)
not
any
(
c
in
chat_template
for
c
in
JINJA_CHARS
)
and
not
Path
(
chat_template
).
exists
()
and
not
Path
(
chat_template
).
exists
()
):
):
raise
ValueErr
or
(
# Try to find the template in the built-in templates direct
or
y
f
"The supplied
chat
template
string (
{
chat_template
}
) "
from
vllm.transformers_utils.
chat
_
template
s.registry
import
(
f
"appears path-like, but doesn't exist!"
CHAT_TEMPLATES_DIR
,
)
)
builtin_template_path
=
CHAT_TEMPLATES_DIR
/
chat_template
if
not
builtin_template_path
.
exists
():
raise
ValueError
(
f
"The supplied chat template string (
{
chat_template
}
) "
f
"appears path-like, but doesn't exist! "
f
"Tried:
{
chat_template
}
and
{
builtin_template_path
}
"
)
else
:
else
:
raise
TypeError
(
f
"
{
type
(
chat_template
)
}
is not a valid chat template type"
)
raise
TypeError
(
f
"
{
type
(
chat_template
)
}
is not a valid chat template type"
)
...
@@ -1173,12 +1181,23 @@ def _load_chat_template(
...
@@ -1173,12 +1181,23 @@ def _load_chat_template(
JINJA_CHARS
=
"{}
\n
"
JINJA_CHARS
=
"{}
\n
"
if
not
any
(
c
in
chat_template
for
c
in
JINJA_CHARS
):
if
not
any
(
c
in
chat_template
for
c
in
JINJA_CHARS
):
msg
=
(
# Try to load from the built-in templates directory
f
"The supplied chat template (
{
chat_template
}
) "
from
vllm.transformers_utils.chat_templates.registry
import
(
f
"looks like a file path, but it failed to be "
CHAT_TEMPLATES_DIR
,
f
"opened. Reason:
{
e
}
"
)
)
raise
ValueError
(
msg
)
from
e
builtin_template_path
=
CHAT_TEMPLATES_DIR
/
chat_template
try
:
with
open
(
builtin_template_path
)
as
f
:
return
f
.
read
()
except
OSError
:
msg
=
(
f
"The supplied chat template (
{
chat_template
}
) "
f
"looks like a file path, but it failed to be opened. "
f
"Tried:
{
chat_template
}
and
{
builtin_template_path
}
. "
f
"Reason:
{
e
}
"
)
raise
ValueError
(
msg
)
from
e
# If opening a file fails, set chat template to be args to
# If opening a file fails, set chat template to be args to
# ensure we decode so our escape are interpreted correctly
# ensure we decode so our escape are interpreted correctly
...
...
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