Update apis/chat_api.py
Browse files- apis/chat_api.py +27 -1
apis/chat_api.py
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
import argparse
|
|
|
2 |
import os
|
3 |
import sys
|
4 |
import time
|
5 |
import uvicorn
|
6 |
|
|
|
7 |
from fastapi import FastAPI, Depends
|
|
|
8 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
9 |
from pydantic import BaseModel, Field
|
10 |
from typing import Union
|
@@ -46,6 +49,20 @@ class ChatAPIApp:
|
|
46 |
"created": current_time,
|
47 |
"owned_by": "mistralai",
|
48 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
],
|
50 |
}
|
51 |
return self.available_models
|
@@ -118,19 +135,28 @@ class ChatAPIApp:
|
|
118 |
data_response = streamer.chat_return_dict(stream_response)
|
119 |
return data_response
|
120 |
|
121 |
-
|
122 |
for prefix in ["", "/v1", "/api", "/api/v1"]:
|
|
|
|
|
|
|
|
|
|
|
123 |
self.app.get(
|
124 |
prefix + "/models",
|
125 |
summary="Get available models",
|
|
|
126 |
)(self.get_available_models)
|
127 |
|
128 |
self.app.post(
|
129 |
prefix + "/chat/completions",
|
130 |
summary="Chat completions in conversation session",
|
|
|
131 |
)(self.chat_completions)
|
132 |
|
133 |
|
|
|
|
|
134 |
class ArgParser(argparse.ArgumentParser):
|
135 |
def __init__(self, *args, **kwargs):
|
136 |
super(ArgParser, self).__init__(*args, **kwargs)
|
|
|
1 |
import argparse
|
2 |
+
import markdown2
|
3 |
import os
|
4 |
import sys
|
5 |
import time
|
6 |
import uvicorn
|
7 |
|
8 |
+
from pathlib import Path
|
9 |
from fastapi import FastAPI, Depends
|
10 |
+
from fastapi.responses import HTMLResponse
|
11 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
12 |
from pydantic import BaseModel, Field
|
13 |
from typing import Union
|
|
|
49 |
"created": current_time,
|
50 |
"owned_by": "mistralai",
|
51 |
},
|
52 |
+
{
|
53 |
+
"id": "nous-mixtral-8x7b",
|
54 |
+
"description": "[NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO]: https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
55 |
+
"object": "model",
|
56 |
+
"created": current_time,
|
57 |
+
"owned_by": "NousResearch",
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"id": "gemma-7b",
|
61 |
+
"description": "[google/gemma-7b-it]: https://huggingface.co/google/gemma-7b-it",
|
62 |
+
"object": "model",
|
63 |
+
"created": current_time,
|
64 |
+
"owned_by": "Google",
|
65 |
+
},
|
66 |
],
|
67 |
}
|
68 |
return self.available_models
|
|
|
135 |
data_response = streamer.chat_return_dict(stream_response)
|
136 |
return data_response
|
137 |
|
138 |
+
def setup_routes(self):
|
139 |
for prefix in ["", "/v1", "/api", "/api/v1"]:
|
140 |
+
if prefix in ["/api/v1"]:
|
141 |
+
include_in_schema = True
|
142 |
+
else:
|
143 |
+
include_in_schema = False
|
144 |
+
|
145 |
self.app.get(
|
146 |
prefix + "/models",
|
147 |
summary="Get available models",
|
148 |
+
include_in_schema=include_in_schema,
|
149 |
)(self.get_available_models)
|
150 |
|
151 |
self.app.post(
|
152 |
prefix + "/chat/completions",
|
153 |
summary="Chat completions in conversation session",
|
154 |
+
include_in_schema=include_in_schema,
|
155 |
)(self.chat_completions)
|
156 |
|
157 |
|
158 |
+
|
159 |
+
|
160 |
class ArgParser(argparse.ArgumentParser):
|
161 |
def __init__(self, *args, **kwargs):
|
162 |
super(ArgParser, self).__init__(*args, **kwargs)
|