Skip to content

Commit

Permalink
Model adapter matching improve by prioritizing last folder of model p…
Browse files Browse the repository at this point in the history
…ath (#1924)

Co-authored-by: CrazyShipOne <>
  • Loading branch information
CrazyShipOne authored Jul 13, 2023
1 parent 77febba commit 961b5de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,18 @@ def register_model_adapter(cls):
@cache
def get_model_adapter(model_path: str) -> BaseModelAdapter:
"""Get a model adapter for a model_path."""
model_path_basename = os.path.basename(os.path.normpath(model_path))

# Try the basename of model_path at first
for adapter in model_adapters:
if adapter.match(model_path_basename) and type(adapter) != BaseModelAdapter:
return adapter

# Then try the full path
for adapter in model_adapters:
if adapter.match(model_path):
return adapter

raise ValueError(f"No valid model adapter for {model_path}")


Expand Down

0 comments on commit 961b5de

Please sign in to comment.