Skip to content

Commit

Permalink
Support CORS for openai api server
Browse files Browse the repository at this point in the history
  • Loading branch information
aisensiy committed Sep 26, 2023
1 parent 97dcdff commit 171368f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lmdeploy/serve/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import fire
import uvicorn
from fastapi import BackgroundTasks, FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, StreamingResponse

from lmdeploy.serve.async_engine import AsyncEngine
Expand All @@ -29,6 +30,16 @@ class VariableInterface:

app = FastAPI(docs_url='/')

origins = ['*']

app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=['*'],
allow_headers=['*'],
)


def get_model_list():
"""Available models.
Expand Down

0 comments on commit 171368f

Please sign in to comment.