lcipolina commited on
Commit
4ac41c0
·
verified ·
1 Parent(s): 182fb1c

Enhanced model name cleaner

Browse files
Files changed (1) hide show
  1. ui/utils.py +31 -10
ui/utils.py CHANGED
@@ -10,7 +10,8 @@ def clean_model_name(model_name: str) -> str:
10
  """
11
  Clean up long model names to display only the essential model name.
12
 
13
- This function handles various model naming patterns from different providers:
 
14
  - LiteLLM models with provider prefixes
15
  - vLLM models with prefixes
16
  - Models with slash-separated paths
@@ -24,9 +25,13 @@ def clean_model_name(model_name: str) -> str:
24
  Cleaned model name (e.g., "Meta-Llama-3.1-8B-Instruct-Turbo")
25
 
26
  Examples:
27
- >>> clean_model_name("litellm_together_ai/meta-llama/Meta-Llama-3.1-8B")
 
 
28
  "Meta-Llama-3.1-8B"
29
- >>> clean_model_name("litellm_fireworks_ai/accounts/fireworks/models/glm-4p5-air")
 
 
30
  "glm-4p5-air"
31
  >>> clean_model_name("vllm_Qwen2-7B-Instruct")
32
  "Qwen2-7B-Instruct"
@@ -89,8 +94,13 @@ def clean_model_name(model_name: str) -> str:
89
  if model_name.startswith("litellm_"):
90
  parts = model_name.split("_")
91
 
92
- # Handle Fireworks AI pattern: litellm_fireworks_ai_accounts_fireworks_models_*
93
- if "fireworks" in model_name and "accounts" in model_name and "models" in model_name:
 
 
 
 
 
94
  try:
95
  models_idx = parts.index("models")
96
  model_parts = parts[models_idx + 1:]
@@ -99,14 +109,25 @@ def clean_model_name(model_name: str) -> str:
99
  pass
100
 
101
  # Handle Together AI pattern: litellm_together_ai_meta_llama_*
102
- # Original: litellm_together_ai/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo
103
- # Becomes: litellm_together_ai_meta_llama_Meta_Llama_3.1_8B_Instruct_Turbo
 
 
104
  # We want: Meta-Llama-3.1-8B-Instruct-Turbo
105
- if "together" in model_name and "meta" in model_name and "llama" in model_name:
 
 
 
 
106
  try:
107
- # Find "meta" and "llama" - the model name starts after "meta_llama_"
 
108
  for i, part in enumerate(parts):
109
- if part == "meta" and i + 1 < len(parts) and parts[i + 1] == "llama":
 
 
 
 
110
  # Model name starts after "meta_llama_"
111
  model_parts = parts[i + 2:]
112
  return "-".join(model_parts)
 
10
  """
11
  Clean up long model names to display only the essential model name.
12
 
13
+ This function handles various model naming patterns
14
+ from different providers:
15
  - LiteLLM models with provider prefixes
16
  - vLLM models with prefixes
17
  - Models with slash-separated paths
 
25
  Cleaned model name (e.g., "Meta-Llama-3.1-8B-Instruct-Turbo")
26
 
27
  Examples:
28
+ >>> clean_model_name(
29
+ "litellm_together_ai/meta-llama/Meta-Llama-3.1-8B"
30
+ )
31
  "Meta-Llama-3.1-8B"
32
+ >>> clean_model_name(
33
+ "litellm_fireworks_ai/accounts/fireworks/models/glm-4p5-air"
34
+ )
35
  "glm-4p5-air"
36
  >>> clean_model_name("vllm_Qwen2-7B-Instruct")
37
  "Qwen2-7B-Instruct"
 
94
  if model_name.startswith("litellm_"):
95
  parts = model_name.split("_")
96
 
97
+ # Handle Fireworks AI pattern:
98
+ # litellm_fireworks_ai_accounts_fireworks_models_*
99
+ if (
100
+ "fireworks" in model_name
101
+ and "accounts" in model_name
102
+ and "models" in model_name
103
+ ):
104
  try:
105
  models_idx = parts.index("models")
106
  model_parts = parts[models_idx + 1:]
 
109
  pass
110
 
111
  # Handle Together AI pattern: litellm_together_ai_meta_llama_*
112
+ # Original:
113
+ # litellm_together_ai/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo
114
+ # Becomes:
115
+ # litellm_together_ai_meta_llama_Meta_Llama_3.1_8B_Instruct_Turbo
116
  # We want: Meta-Llama-3.1-8B-Instruct-Turbo
117
+ if (
118
+ "together" in model_name
119
+ and "meta" in model_name
120
+ and "llama" in model_name
121
+ ):
122
  try:
123
+ # Find "meta" and "llama" -
124
+ # the model name starts after "meta_llama_"
125
  for i, part in enumerate(parts):
126
+ if (
127
+ part == "meta"
128
+ and i + 1 < len(parts)
129
+ and parts[i + 1] == "llama"
130
+ ):
131
  # Model name starts after "meta_llama_"
132
  model_parts = parts[i + 2:]
133
  return "-".join(model_parts)