List all supported models and their download status.
(args)
| 1802 | |
| 1803 | |
| 1804 | def cmd_list(args): |
| 1805 | """List all supported models and their download status.""" |
| 1806 | PIPELINE_DISPLAY = { |
| 1807 | "text-generation": "Text Generation", |
| 1808 | "image-text-to-text": "Vision", |
| 1809 | "automatic-speech-recognition": "Speech Recognition", |
| 1810 | "feature-extraction": "Embeddings", |
| 1811 | "voice-activity-detection": "Voice Activity Detection", |
| 1812 | } |
| 1813 | PIPELINE_ORDER = list(PIPELINE_DISPLAY.keys()) |
| 1814 | SHOW_TAGS = {"tools", "vision", "embed", "transcription"} |
| 1815 | EMBED_ALIASES = {"text-embed", "image-embed", "speech-embed"} |
| 1816 | |
| 1817 | DIM = '\033[2m' |
| 1818 | BOLD = '\033[1m' |
| 1819 | |
| 1820 | def filter_tags(tags): |
| 1821 | result = set() |
| 1822 | for t in tags: |
| 1823 | if t in SHOW_TAGS: |
| 1824 | result.add(t) |
| 1825 | elif t in EMBED_ALIASES: |
| 1826 | result.add("embed") |
| 1827 | return sorted(result) |
| 1828 | |
| 1829 | def get_dir_size(path): |
| 1830 | total = 0 |
| 1831 | for entry in path.rglob('*'): |
| 1832 | if entry.is_file(): |
| 1833 | total += entry.stat().st_size |
| 1834 | return total |
| 1835 | |
| 1836 | def format_size(size_bytes): |
| 1837 | if size_bytes >= 1_000_000_000: |
| 1838 | return f"{size_bytes / 1_073_741_824:.1f} GB" |
| 1839 | return f"{size_bytes / 1_048_576:.0f} MB" |
| 1840 | |
| 1841 | # Group models by pipeline_tag preserving order |
| 1842 | groups = {} |
| 1843 | for entry in MODELS_REGISTRY: |
| 1844 | tag = entry["pipeline_tag"] |
| 1845 | groups.setdefault(tag, []).append(entry) |
| 1846 | |
| 1847 | # Find max model name length for alignment |
| 1848 | max_name = max(len(e["model"]) for e in MODELS_REGISTRY) |
| 1849 | max_tags_len = 20 |
| 1850 | |
| 1851 | only_downloaded = getattr(args, 'downloaded', False) |
| 1852 | |
| 1853 | if only_downloaded: |
| 1854 | print(f"\n {BOLD}Downloaded Models{NC}") |
| 1855 | else: |
| 1856 | print(f"\n {BOLD}Supported Models{NC}") |
| 1857 | print(f" {'─' * 66}") |
| 1858 | |
| 1859 | for ptag in PIPELINE_ORDER: |
| 1860 | models = groups.get(ptag) |
| 1861 | if not models: |
no test coverage detected