Hansimov commited on
Commit
245d9fd
1 Parent(s): acbd8bf

:zap: [Enhance] Align /models response with openai format

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +21 -15
apis/chat_api.py CHANGED
@@ -25,21 +25,27 @@ class ChatAPIApp:
25
  self.setup_routes()
26
 
27
  def get_available_models(self):
 
28
  # ANCHOR[id=available-models]: Available models
29
- self.available_models = [
30
- {
31
- "id": "mixtral-8x7b",
32
- "description": "[mistralai/Mixtral-8x7B-Instruct-v0.1]: https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1",
33
- },
34
- {
35
- "id": "mistral-7b",
36
- "description": "[mistralai/Mistral-7B-Instruct-v0.2]: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
37
- },
38
- # {
39
- # "id": "openchat-3.5",
40
- # "description": "[openchat/openchat-3.5-1210]: https://huggingface.co/openchat/openchat-3.5-1210",
41
- # },
42
- ]
 
 
 
 
 
43
  return self.available_models
44
 
45
  def extract_api_key(
@@ -111,7 +117,7 @@ class ChatAPIApp:
111
  return data_response
112
 
113
  def setup_routes(self):
114
- for prefix in ["", "/v1", "/api/v1"]:
115
  self.app.get(
116
  prefix + "/models",
117
  summary="Get available models",
 
25
  self.setup_routes()
26
 
27
  def get_available_models(self):
28
+ # https://platform.openai.com/docs/api-reference/models/list
29
  # ANCHOR[id=available-models]: Available models
30
+ self.available_models = {
31
+ "object": "list",
32
+ "data": [
33
+ {
34
+ "id": "mixtral-8x7b",
35
+ "description": "[mistralai/Mixtral-8x7B-Instruct-v0.1]: https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1",
36
+ "object": "model",
37
+ "created": 1700000000,
38
+ "owned_by": "mistralai",
39
+ },
40
+ {
41
+ "id": "mistral-7b",
42
+ "description": "[mistralai/Mistral-7B-Instruct-v0.2]: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
43
+ "object": "model",
44
+ "created": 1700000000,
45
+ "owned_by": "mistralai",
46
+ },
47
+ ],
48
+ }
49
  return self.available_models
50
 
51
  def extract_api_key(
 
117
  return data_response
118
 
119
  def setup_routes(self):
120
+ for prefix in ["", "/v1", "/api", "/api/v1"]:
121
  self.app.get(
122
  prefix + "/models",
123
  summary="Get available models",