Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
7c94eaee
Unverified
Commit
7c94eaee
authored
Oct 13, 2025
by
Simo Lin
Committed by
GitHub
Oct 13, 2025
Browse files
[router] allow tokenizer path to be dir (#11530)
parent
13d596c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
sgl-router/src/tokenizer/factory.rs
sgl-router/src/tokenizer/factory.rs
+25
-0
No files found.
sgl-router/src/tokenizer/factory.rs
View file @
7c94eaee
...
...
@@ -44,6 +44,31 @@ pub fn create_tokenizer_with_chat_template(
return
Err
(
Error
::
msg
(
format!
(
"File not found: {}"
,
file_path
)));
}
// If path is a directory, search for tokenizer files
if
path
.is_dir
()
{
let
tokenizer_json
=
path
.join
(
"tokenizer.json"
);
if
tokenizer_json
.exists
()
{
let
chat_template_path
=
chat_template_path
.map
(|
s
|
s
.to_string
())
.or_else
(||
discover_chat_template_in_dir
(
path
));
let
tokenizer_path_str
=
tokenizer_json
.to_str
()
.ok_or_else
(||
{
Error
::
msg
(
format!
(
"Tokenizer path is not valid UTF-8: {:?}"
,
tokenizer_json
))
})
?
;
return
create_tokenizer_with_chat_template
(
tokenizer_path_str
,
chat_template_path
.as_deref
(),
);
}
return
Err
(
Error
::
msg
(
format!
(
"Directory '{}' does not contain a valid tokenizer file (tokenizer.json, tokenizer_config.json, or vocab.json)"
,
file_path
)));
}
// Try to determine tokenizer type from extension
let
extension
=
path
.extension
()
...
...
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