Spaces:
Paused
Paused
:gem: [Feature] ChatAPI: Support /v1 prefix
Browse files- apis/chat_api.py +20 -20
apis/chat_api.py
CHANGED
@@ -5,7 +5,6 @@ from sse_starlette.sse import EventSourceResponse
|
|
5 |
from conversations import (
|
6 |
ConversationConnector,
|
7 |
ConversationCreator,
|
8 |
-
ConversationSession,
|
9 |
MessageComposer,
|
10 |
)
|
11 |
|
@@ -136,25 +135,26 @@ class ChatAPIApp:
|
|
136 |
)
|
137 |
|
138 |
def setup_routes(self):
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
158 |
|
159 |
|
160 |
app = ChatAPIApp().app
|
|
|
5 |
from conversations import (
|
6 |
ConversationConnector,
|
7 |
ConversationCreator,
|
|
|
8 |
MessageComposer,
|
9 |
)
|
10 |
|
|
|
135 |
)
|
136 |
|
137 |
def setup_routes(self):
|
138 |
+
for prefix in ["", "/v1"]:
|
139 |
+
self.app.get(
|
140 |
+
prefix + "/models",
|
141 |
+
summary="Get available models",
|
142 |
+
)(self.get_available_models)
|
143 |
+
|
144 |
+
self.app.post(
|
145 |
+
prefix + "/create",
|
146 |
+
summary="Create a conversation session",
|
147 |
+
)(self.create_conversation_session)
|
148 |
+
|
149 |
+
self.app.post(
|
150 |
+
prefix + "/chat",
|
151 |
+
summary="Chat in conversation session",
|
152 |
+
)(self.chat)
|
153 |
+
|
154 |
+
self.app.post(
|
155 |
+
prefix + "/chat/completions",
|
156 |
+
summary="Chat completions in conversation session",
|
157 |
+
)(self.chat_completions)
|
158 |
|
159 |
|
160 |
app = ChatAPIApp().app
|