MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / parse_models_output

Function parse_models_output

scripts/python_ui/streamlit.py:113–138  ·  view source on GitHub ↗

Parse the output of fabric --listmodels command.

(output: str)

Source from the content-addressed store, hash-verified

111
112
113def parse_models_output(output: str) -> Dict[str, List[str]]:
114 """Parse the output of fabric --listmodels command."""
115 logger.debug("Parsing models output")
116 providers = {}
117 current_provider = None
118
119 lines = output.split("\n")
120 for line in lines:
121 line = line.strip()
122 if not line:
123 continue
124
125 if line == "Available models:":
126 continue
127
128 if not line.startswith("\t") and not line.startswith("["):
129 current_provider = line.strip()
130 providers[current_provider] = []
131 elif current_provider and (line.startswith("\t") or line.startswith("[")):
132 model = line.strip()
133 if "[" in model and "]" in model:
134 model = model.split("]", 1)[1].strip()
135 providers[current_provider].append(model)
136
137 logger.debug(f"Found providers: {list(providers.keys())}")
138 return providers
139
140
141def safe_run_command(command: List[str], retry: bool = True) -> Tuple[bool, str, str]:

Callers 1

fetch_models_onceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected