Spaces:
Sleeping
Sleeping
Update apis/chat_api.py
Browse files- apis/chat_api.py +10 -0
apis/chat_api.py
CHANGED
@@ -16,6 +16,8 @@ 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:
|
21 |
def __init__(self):
|
@@ -27,6 +29,14 @@ class ChatAPIApp:
|
|
27 |
)
|
28 |
self.setup_routes()
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def get_available_models(self):
|
31 |
# https://platform.openai.com/docs/api-reference/models/list
|
32 |
# ANCHOR[id=available-models]: Available models
|
|
|
16 |
from messagers.message_composer import MessageComposer
|
17 |
from mocks.stream_chat_mocker import stream_chat_mock
|
18 |
|
19 |
+
from fastapi.middleware.cors import CORSMiddleware
|
20 |
+
|
21 |
|
22 |
class ChatAPIApp:
|
23 |
def __init__(self):
|
|
|
29 |
)
|
30 |
self.setup_routes()
|
31 |
|
32 |
+
self.app.add_middleware(
|
33 |
+
CORSMiddleware,
|
34 |
+
allow_origins=["*"], # You can specify specific origins here
|
35 |
+
allow_credentials=True,
|
36 |
+
allow_methods=["*"], # Or specify just the methods you need: ["GET", "POST"]
|
37 |
+
allow_headers=["*"], # Or specify headers you need
|
38 |
+
)
|
39 |
+
|
40 |
def get_available_models(self):
|
41 |
# https://platform.openai.com/docs/api-reference/models/list
|
42 |
# ANCHOR[id=available-models]: Available models
|