Skip to content

Commit

Permalink
FEAT: Reduce code redundancy by setting default values (#2711)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengjunfeng11 authored Dec 27, 2024
1 parent fd52f65 commit ae7b3f6
Showing 1 changed file with 15 additions and 36 deletions.
51 changes: 15 additions & 36 deletions xinference/model/llm/llm_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,46 +972,25 @@ def _apply_format_to_model_id(spec: LLMSpecV1, q: str) -> LLMSpecV1:
return spec

# priority: download_hub > download_from_modelscope() and download_from_csghub()
if download_hub == "modelscope":
all_families = (
BUILTIN_MODELSCOPE_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
elif download_hub == "openmind_hub":
all_families = (
BUILTIN_OPENMIND_HUB_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
elif download_hub == "csghub":
all_families = (
BUILTIN_CSGHUB_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
elif download_hub == "huggingface":
all_families = BUILTIN_LLM_FAMILIES + user_defined_llm_families
# set base model
base_families = BUILTIN_LLM_FAMILIES + user_defined_llm_families
hub_families_map = {
"modelscope": BUILTIN_MODELSCOPE_LLM_FAMILIES,
"openmind_hub": BUILTIN_OPENMIND_HUB_LLM_FAMILIES,
"csghub": BUILTIN_CSGHUB_LLM_FAMILIES,
}
if download_hub == "huggingface":
all_families = base_families
elif download_hub in hub_families_map:
all_families = hub_families_map[download_hub] + base_families
elif download_from_modelscope():
all_families = (
BUILTIN_MODELSCOPE_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
all_families = BUILTIN_MODELSCOPE_LLM_FAMILIES + base_families
elif download_from_openmind_hub():
all_families = (
BUILTIN_OPENMIND_HUB_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
all_families = BUILTIN_OPENMIND_HUB_LLM_FAMILIES + base_families
elif download_from_csghub():
all_families = (
BUILTIN_CSGHUB_LLM_FAMILIES
+ BUILTIN_LLM_FAMILIES
+ user_defined_llm_families
)
all_families = BUILTIN_CSGHUB_LLM_FAMILIES + base_families
else:
all_families = BUILTIN_LLM_FAMILIES + user_defined_llm_families
all_families = base_families

for family in all_families:
if model_name != family.model_name:
Expand Down

0 comments on commit ae7b3f6

Please sign in to comment.