1313class AI_API_ENDPOINT_ENUM (StrEnum ):
1414 AI_API_MODELS_GITHUB = 'models.github.ai'
1515 AI_API_GITHUBCOPILOT = 'api.githubcopilot.com'
16+ AI_API_OPENAI = 'api.openai.com'
1617
1718 def to_url (self ):
1819 """
@@ -23,6 +24,8 @@ def to_url(self):
2324 return f"https://{ self } "
2425 case AI_API_ENDPOINT_ENUM .AI_API_MODELS_GITHUB :
2526 return f"https://{ self } /inference"
27+ case AI_API_ENDPOINT_ENUM .AI_API_OPENAI :
28+ return f"https://{ self } /v1"
2629 case _:
2730 raise ValueError (f"Unsupported endpoint: { self } " )
2831
@@ -61,6 +64,8 @@ def list_capi_models(token: str) -> dict[str, dict]:
6164 models_catalog = 'models'
6265 case AI_API_ENDPOINT_ENUM .AI_API_MODELS_GITHUB :
6366 models_catalog = 'catalog/models'
67+ case AI_API_ENDPOINT_ENUM .AI_API_OPENAI :
68+ models_catalog = 'models'
6469 case _:
6570 raise ValueError (f"Unsupported Model Endpoint: { api_endpoint } \n "
6671 f"Supported endpoints: { [e .to_url () for e in AI_API_ENDPOINT_ENUM ]} " )
@@ -77,6 +82,8 @@ def list_capi_models(token: str) -> dict[str, dict]:
7782 models_list = r .json ().get ('data' , [])
7883 case AI_API_ENDPOINT_ENUM .AI_API_MODELS_GITHUB :
7984 models_list = r .json ()
85+ case AI_API_ENDPOINT_ENUM .AI_API_OPENAI :
86+ models_list = r .json ().get ('data' , [])
8087 for model in models_list :
8188 models [model .get ('id' )] = dict (model )
8289 except httpx .RequestError as e :
@@ -98,6 +105,13 @@ def supports_tool_calls(model: str, models: dict) -> bool:
98105 case AI_API_ENDPOINT_ENUM .AI_API_MODELS_GITHUB :
99106 return 'tool-calling' in models .get (model , {}).\
100107 get ('capabilities' , [])
108+ case AI_API_ENDPOINT_ENUM .AI_API_OPENAI :
109+ # OpenAI doesn't expose capabilities in the models list
110+ # Check if model name indicates function calling support
111+ model_lower = model .lower ()
112+ return any ([
113+ 'gpt-' in model_lower ,
114+ ])
101115 case _:
102116 raise ValueError (
103117 f"Unsupported Model Endpoint: { api_endpoint } \n "
0 commit comments