Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Cheema
3c9efe103d Merge pull request #590 from metaspartan/fix-models-api
Fix the /v1/models API to output proper OpenAI compatible endpoint
2025-01-07 02:32:06 +00:00
Carsen Klock
627bfcae7c Fix the /v1/models API to output proper OpenAI compatible endpoint
Modify the `/v1/models` API to output a proper OpenAI compatible endpoint with an object and a `data` object containing the models list.

* Change the `handle_get_models` method in `exo/api/chatgpt_api.py` to wrap the models list in an object with a `data` field.
* Add an `object` field with the value "list" to the response format.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/metaspartan/exo?shareId=XXXX-XXXX-XXXX-XXXX).
2025-01-06 01:20:30 -07:00

View File

@@ -291,7 +291,8 @@ class ChatGPTAPI:
)
async def handle_get_models(self, request):
return web.json_response([{"id": model_name, "object": "model", "owned_by": "exo", "ready": True} for model_name, _ in model_cards.items()])
models_list = [{"id": model_name, "object": "model", "owned_by": "exo", "ready": True} for model_name, _ in model_cards.items()]
return web.json_response({"object": "list", "data": models_list})
async def handle_post_chat_token_encode(self, request):
data = await request.json()