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

Function parse_models_output

scripts/python_ui/streamlit.py:112–137  ·  view source on GitHub ↗

Parse the output of fabric --listmodels command.

(output: str)

Source from the content-addressed store, hash-verified

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