fastapi / main.py
ka1kuk's picture
Update main.py
01b0e1c
raw
history blame
635 Bytes
import Linlada
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware( # add the middleware
CORSMiddleware,
allow_credentials=True, # allow credentials
allow_origins=["*"], # allow all origins
allow_methods=["*"], # allow all methods
allow_headers=["*"], # allow all headers
)
@app.get("/")
def hello():
return "Hello, I'm Artist"
@app.post("/generate/{message}")
def generate_completion(message: str):
response = Linlada._create_completion(model='gpt-4', messages=[{"role": 'user', "content": message}], stream=False)
return response