[Model-Gateway: grpc]: create tokenizer with chat template (#17052)
Signed-off-by: jeff.ye <jeff.ye@novita.ai>
This commit is contained in:
@@ -578,7 +578,7 @@ impl JobQueue {
|
|||||||
tokenizer_path: None,
|
tokenizer_path: None,
|
||||||
reasoning_parser: None,
|
reasoning_parser: None,
|
||||||
tool_parser: None,
|
tool_parser: None,
|
||||||
chat_template: None,
|
chat_template: router_config.chat_template.clone(),
|
||||||
bootstrap_port: None,
|
bootstrap_port: None,
|
||||||
health_check_timeout_secs: router_config.health_check.timeout_secs,
|
health_check_timeout_secs: router_config.health_check.timeout_secs,
|
||||||
health_check_interval_secs: router_config
|
health_check_interval_secs: router_config
|
||||||
@@ -649,7 +649,7 @@ impl JobQueue {
|
|||||||
tokenizer_path: None,
|
tokenizer_path: None,
|
||||||
reasoning_parser: None,
|
reasoning_parser: None,
|
||||||
tool_parser: None,
|
tool_parser: None,
|
||||||
chat_template: None,
|
chat_template: router_config.chat_template.clone(),
|
||||||
bootstrap_port,
|
bootstrap_port,
|
||||||
health_check_timeout_secs: router_config.health_check.timeout_secs,
|
health_check_timeout_secs: router_config.health_check.timeout_secs,
|
||||||
health_check_interval_secs: router_config.health_check.check_interval_secs,
|
health_check_interval_secs: router_config.health_check.check_interval_secs,
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ impl StepExecutor<LocalWorkerWorkflowData> for RegisterTokenizerStep {
|
|||||||
.actual_workers
|
.actual_workers
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| WorkflowError::ContextValueNotFound("workers".to_string()))?;
|
.ok_or_else(|| WorkflowError::ContextValueNotFound("workers".to_string()))?;
|
||||||
|
// Get chat_template: worker config > global router config
|
||||||
|
let chat_template = context
|
||||||
|
.data
|
||||||
|
.config
|
||||||
|
.chat_template
|
||||||
|
.clone()
|
||||||
|
.or_else(|| app_context.router_config.chat_template.clone());
|
||||||
|
|
||||||
for worker in workers.iter() {
|
for worker in workers.iter() {
|
||||||
let model_id = worker.model_id().to_string();
|
let model_id = worker.model_id().to_string();
|
||||||
@@ -55,12 +62,17 @@ impl StepExecutor<LocalWorkerWorkflowData> for RegisterTokenizerStep {
|
|||||||
|
|
||||||
// Load tokenizer with thread safe lock
|
// Load tokenizer with thread safe lock
|
||||||
let tokenizer_path_owned = tokenizer_path.clone();
|
let tokenizer_path_owned = tokenizer_path.clone();
|
||||||
|
let template = chat_template.clone();
|
||||||
if let Err(e) = app_context
|
if let Err(e) = app_context
|
||||||
.tokenizer_registry
|
.tokenizer_registry
|
||||||
.load(&tokenizer_id, &model_id, &source, || async move {
|
.load(&tokenizer_id, &model_id, &source, move || {
|
||||||
factory::create_tokenizer_async(&tokenizer_path_owned)
|
let path = tokenizer_path_owned;
|
||||||
|
let tmpl = template;
|
||||||
|
async move {
|
||||||
|
factory::create_tokenizer_async_with_chat_template(&path, tmpl.as_deref())
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user