From d1c4e68f8be19fb9df3c46b15d72f7e3a6293da0 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sun, 1 Oct 2023 23:07:49 -0600 Subject: [PATCH] fix openai models response --- llm_server/routes/openai/models.py | 53 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/llm_server/routes/openai/models.py b/llm_server/routes/openai/models.py index 39931f8..9f2845d 100644 --- a/llm_server/routes/openai/models.py +++ b/llm_server/routes/openai/models.py @@ -25,38 +25,37 @@ def openai_list_models(): else: running_model = redis.get('running_model', 'ERROR', dtype=str) oai = fetch_openai_models() - r = [] + r = { + "object": "list", + "data": oai + } + # TODO: verify this works if opts.openai_expose_our_model: - r = [{ - "object": "list", - "data": [ + r["data"].insert(0, { + "id": running_model, + "object": "model", + "created": int(server_start_time.timestamp()), + "owned_by": opts.llm_middleware_name, + "permission": [ { "id": running_model, - "object": "model", + "object": "model_permission", "created": int(server_start_time.timestamp()), - "owned_by": opts.llm_middleware_name, - "permission": [ - { - "id": running_model, - "object": "model_permission", - "created": int(server_start_time.timestamp()), - "allow_create_engine": False, - "allow_sampling": False, - "allow_logprobs": False, - "allow_search_indices": False, - "allow_view": True, - "allow_fine_tuning": False, - "organization": "*", - "group": None, - "is_blocking": False - } - ], - "root": None, - "parent": None + "allow_create_engine": False, + "allow_sampling": False, + "allow_logprobs": False, + "allow_search_indices": False, + "allow_view": True, + "allow_fine_tuning": False, + "organization": "*", + "group": None, + "is_blocking": False } - ] - }] - response = jsonify_pretty(r + oai), 200 + ], + "root": None, + "parent": None + }) + response = jsonify_pretty(r), 200 return response