Spaces:
Running
Running
File size: 2,302 Bytes
c92c0ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
from collections import namedtuple
from typing import List
ModelInfo = namedtuple("ModelInfo", ["simple_name", "link", "description"])
model_info = {}
def register_model_info(
full_names: List[str], simple_name: str, link: str, description: str
):
info = ModelInfo(simple_name, link, description)
for full_name in full_names:
model_info[full_name] = info
def get_model_info(name: str) -> ModelInfo:
if name in model_info:
return model_info[name]
else:
# To fix this, please use `register_model_info` to register your model
return ModelInfo(
name, "", "Register the description at fastchat/model/model_registry.py"
)
def get_model_description_md(model_list):
model_description_md = """
| | | | | | | | | | | |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
"""
ct = 0
visited = set()
for i, name in enumerate(model_list):
model_source, model_name, model_type = name.split("_")
minfo = get_model_info(model_name)
if minfo.simple_name in visited:
continue
visited.add(minfo.simple_name)
# one_model_md = f"[{minfo.simple_name}]({minfo.link}): {minfo.description}"
one_model_md = f"{minfo.simple_name}"
if ct % 11 == 0:
model_description_md += "|"
model_description_md += f" {one_model_md} |"
if ct % 11 == 10:
model_description_md += "\n"
ct += 1
return model_description_md
def get_video_model_description_md(model_list):
model_description_md = """
| | | | | | |
| ---- | ---- | ---- | ---- | ---- | ---- |
"""
ct = 0
visited = set()
for i, name in enumerate(model_list):
model_source, model_name, model_type = name.split("_")
minfo = get_model_info(model_name)
if minfo.simple_name in visited:
continue
visited.add(minfo.simple_name)
# one_model_md = f"[{minfo.simple_name}]({minfo.link}): {minfo.description}"
one_model_md = f"{minfo.simple_name}"
if ct % 7 == 0:
model_description_md += "|"
model_description_md += f" {one_model_md} |"
if ct % 7 == 6:
model_description_md += "\n"
ct += 1
return model_description_md
|