MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/optillm / Models

Class Models

optillm/litellm_wrapper.py:41–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 completions = Completions()
40
41 class Models:
42 @staticmethod
43 def list():
44 try:
45 # Get all valid models from LiteLLM
46 valid_models = get_valid_models()
47
48 # Format the response to match OpenAI's API format
49 model_list = []
50 for model in valid_models:
51 model_list.append({
52 "id": model,
53 "object": "model",
54 "created": int(time.time()),
55 "owned_by": "litellm"
56 })
57
58 return {
59 "object": "list",
60 "data": model_list
61 }
62 except Exception as e:
63 # Fallback to a basic list if there's an error
64 print(f"Error fetching LiteLLM models: {str(e)}")
65 return {
66 "object": "list",
67 "data": [
68 {"id": "gpt-4o-mini", "object": "model", "created": int(time.time()), "owned_by": "litellm"},
69 {"id": "gpt-4o", "object": "model", "created": int(time.time()), "owned_by": "litellm"},
70 {"id": "command-nightly", "object": "model", "created": int(time.time()), "owned_by": "litellm"},
71 {"id": "claude-3-opus-20240229", "object": "model", "created": int(time.time()), "owned_by": "litellm"},
72 {"id": "claude-3-sonnet-20240229", "object": "model", "created": int(time.time()), "owned_by": "litellm"},
73 {"id": "gemini-1.5-pro-latest", "object": "model", "created": int(time.time()), "owned_by": "litellm"}
74 ]
75 }
76 models = Models()

Callers 1

LiteLLMWrapperClass · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected