Former-commit-id: 23c0d36abe881d9be839d5c647841bdef178307b
This commit is contained in:
hiyouga
2023-06-30 10:09:59 +08:00
parent 40ab36456c
commit d720f67e6c
2 changed files with 11 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import uvicorn
from threading import Thread
from pydantic import BaseModel, Field
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
from transformers import TextIteratorStreamer
from starlette.responses import StreamingResponse
@@ -34,6 +35,15 @@ async def lifespan(app: FastAPI): # collects GPU memory
app = FastAPI(lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
class ModelCard(BaseModel):
id: str
object: str = "model"