[model-gateway] Fix logging module name, parse endpoint context, and tokenizer factory (#15782)
This commit is contained in:
@@ -254,14 +254,27 @@ pub async fn create_tokenizer_async_with_chat_template(
|
||||
}
|
||||
|
||||
// Check if it's a GPT model name that should use Tiktoken
|
||||
if model_name_or_path.contains("gpt-")
|
||||
// Only match specific OpenAI model patterns to avoid catching HuggingFace models like "openai/gpt-oss-20b"
|
||||
if model_name_or_path.contains("gpt-4")
|
||||
|| model_name_or_path.contains("gpt-3.5")
|
||||
|| model_name_or_path.contains("gpt-3")
|
||||
|| model_name_or_path.contains("turbo")
|
||||
|| model_name_or_path.contains("davinci")
|
||||
|| model_name_or_path.contains("curie")
|
||||
|| model_name_or_path.contains("babbage")
|
||||
|| model_name_or_path.contains("ada")
|
||||
|| model_name_or_path.contains("codex")
|
||||
{
|
||||
let tokenizer = TiktokenTokenizer::from_model_name(model_name_or_path)?;
|
||||
return Ok(Arc::new(tokenizer));
|
||||
// Try tiktoken first, but fall back to HuggingFace if it fails
|
||||
match TiktokenTokenizer::from_model_name(model_name_or_path) {
|
||||
Ok(tokenizer) => return Ok(Arc::new(tokenizer)),
|
||||
Err(e) => {
|
||||
debug!(
|
||||
"Tiktoken failed for '{}': {}, falling back to HuggingFace",
|
||||
model_name_or_path, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to download tokenizer files from HuggingFace
|
||||
|
||||
Reference in New Issue
Block a user