Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return last tokenizer if many #441

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions refact_webgui/webgui/selfhost_fastapi_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,12 @@ def _select_default_lora_if_exists(model_name: str, running_models: List[str]):

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

data = ""
async with aiofiles.open(tokenizer_paths[0], mode='r') as f:
async with aiofiles.open(tokenizer_paths[-1], mode='r') as f:
while True:
if not (chunk := await f.read(1024 * 1024)):
break
Expand Down