From 627bfcae7cc4a34474eb5374d74d453d6cc6ddca Mon Sep 17 00:00:00 2001 From: Carsen Klock Date: Mon, 6 Jan 2025 01:20:30 -0700 Subject: [PATCH] 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). --- exo/api/chatgpt_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exo/api/chatgpt_api.py b/exo/api/chatgpt_api.py index ef9634003..820689217 100644 --- a/exo/api/chatgpt_api.py +++ b/exo/api/chatgpt_api.py @@ -291,7 +291,8 @@ async def process_model(model_name, pretty): ) 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()