Skip to content

Commit e693243

Browse files
committed
return last tokenizer if many
1 parent 4048d55 commit e693243

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

refact_webgui/webgui/selfhost_fastapi_completions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,12 @@ def _select_default_lora_if_exists(model_name: str, running_models: List[str]):
311311

312312
async def _local_tokenizer(self, model_path: str) -> str:
313313
model_dir = Path(env.DIR_WEIGHTS) / f"models--{model_path.replace('/', '--')}"
314-
tokenizer_paths = list(model_dir.rglob("tokenizer.json"))
314+
tokenizer_paths = list(sorted(model_dir.rglob("tokenizer.json"), key=lambda p: p.stat().st_ctime))
315315
if not tokenizer_paths:
316316
raise HTTPException(404, detail=f"tokenizer.json for {model_path} does not exist")
317-
if len(tokenizer_paths) > 1:
318-
raise HTTPException(404, detail=f"multiple tokenizer.json for {model_path}")
319317

320318
data = ""
321-
async with aiofiles.open(tokenizer_paths[0], mode='r') as f:
319+
async with aiofiles.open(tokenizer_paths[-1], mode='r') as f:
322320
while True:
323321
if not (chunk := await f.read(1024 * 1024)):
324322
break

0 commit comments

Comments
 (0)