Spaces:
Running
Running
Husnain
commited on
Commit
•
8cfcd80
1
Parent(s):
ec66653
♻️ [Refactor] Move AVAILABLE_MODELS(_DICTS) to constants
Browse files- apis/chat_api.py +7 -39
apis/chat_api.py
CHANGED
@@ -5,16 +5,19 @@ import sys
|
|
5 |
import uvicorn
|
6 |
|
7 |
from pathlib import Path
|
|
|
|
|
8 |
from fastapi import FastAPI, Depends
|
9 |
from fastapi.responses import HTMLResponse
|
10 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
11 |
from pydantic import BaseModel, Field
|
12 |
-
from typing import Union
|
13 |
from sse_starlette.sse import EventSourceResponse, ServerSentEvent
|
14 |
-
|
15 |
-
from networks.message_streamer import MessageStreamer
|
16 |
from messagers.message_composer import MessageComposer
|
17 |
from mocks.stream_chat_mocker import stream_chat_mock
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
class ChatAPIApp:
|
@@ -28,42 +31,7 @@ class ChatAPIApp:
|
|
28 |
self.setup_routes()
|
29 |
|
30 |
def get_available_models(self):
|
31 |
-
|
32 |
-
# ANCHOR[id=available-models]: Available models
|
33 |
-
self.available_models = {
|
34 |
-
"object": "list",
|
35 |
-
"data": [
|
36 |
-
{
|
37 |
-
"id": "mixtral-8x7b",
|
38 |
-
"description": "[mistralai/Mixtral-8x7B-Instruct-v0.1]: https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1",
|
39 |
-
"object": "model",
|
40 |
-
"created": 1700000000,
|
41 |
-
"owned_by": "mistralai",
|
42 |
-
},
|
43 |
-
{
|
44 |
-
"id": "mistral-7b",
|
45 |
-
"description": "[mistralai/Mistral-7B-Instruct-v0.2]: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
|
46 |
-
"object": "model",
|
47 |
-
"created": 1700000000,
|
48 |
-
"owned_by": "mistralai",
|
49 |
-
},
|
50 |
-
{
|
51 |
-
"id": "nous-mixtral-8x7b",
|
52 |
-
"description": "[NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO]: https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
53 |
-
"object": "model",
|
54 |
-
"created": 1700000000,
|
55 |
-
"owned_by": "NousResearch",
|
56 |
-
},
|
57 |
-
{
|
58 |
-
"id": "gemma-7b",
|
59 |
-
"description": "[google/gemma-7b-it]: https://huggingface.co/google/gemma-7b-it",
|
60 |
-
"object": "model",
|
61 |
-
"created": 1700000000,
|
62 |
-
"owned_by": "Google",
|
63 |
-
},
|
64 |
-
],
|
65 |
-
}
|
66 |
-
return self.available_models
|
67 |
|
68 |
def extract_api_key(
|
69 |
credentials: HTTPAuthorizationCredentials = Depends(
|
|
|
5 |
import uvicorn
|
6 |
|
7 |
from pathlib import Path
|
8 |
+
from typing import Union
|
9 |
+
|
10 |
from fastapi import FastAPI, Depends
|
11 |
from fastapi.responses import HTMLResponse
|
12 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
13 |
from pydantic import BaseModel, Field
|
|
|
14 |
from sse_starlette.sse import EventSourceResponse, ServerSentEvent
|
15 |
+
|
|
|
16 |
from messagers.message_composer import MessageComposer
|
17 |
from mocks.stream_chat_mocker import stream_chat_mock
|
18 |
+
from networks.message_streamer import MessageStreamer
|
19 |
+
from utils.logger import logger
|
20 |
+
from constants.models import AVAILABLE_MODELS_DICTS
|
21 |
|
22 |
|
23 |
class ChatAPIApp:
|
|
|
31 |
self.setup_routes()
|
32 |
|
33 |
def get_available_models(self):
|
34 |
+
return {"object": "list", "data": AVAILABLE_MODELS_DICTS}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def extract_api_key(
|
37 |
credentials: HTTPAuthorizationCredentials = Depends(
|