Spaces:
Runtime error
Runtime error
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 | |