MCPcopy
hub / github.com/algorithmicsuperintelligence/optillm / list

Method list

optillm/inference.py:2108–2138  ·  view source on GitHub ↗

Return list of supported models

(self)

Source from the content-addressed store, hash-verified

2106 class Models:
2107 """OpenAI-compatible models interface"""
2108 def list(self):
2109 """Return list of supported models"""
2110 try:
2111 import requests
2112 response = requests.get(
2113 "https://huggingface.co/api/models?sort=downloads&direction=-1&filter=text-generation&limit=20"
2114 )
2115 models = response.json()
2116 model_list = []
2117
2118 for model in models:
2119 if 'pipeline_tag' in model and model['pipeline_tag'] == 'text-generation':
2120 model_list.append({
2121 "id": model['id'],
2122 "object": "model",
2123 "created": int(time.time()),
2124 "owned_by": "huggingface",
2125 })
2126
2127 return {"data": model_list, "object": "list"}
2128 except Exception as e:
2129 logger.warning(f"Failed to fetch models: {e}")
2130 return {
2131 "data": [{
2132 "id": "HuggingFaceTB/SmolLM-135M-Instruct",
2133 "object": "model",
2134 "created": int(time.time()),
2135 "owned_by": "huggingface",
2136 }],
2137 "object": "list"
2138 }
2139
2140def create_inference_client() -> InferenceClient:
2141 """Factory function to create an inference client"""

Callers 2

proxy_modelsFunction · 0.45
_check_providerMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected