Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from fastapi.middleware.cors import CORSMiddleware | |
from inference import rag_chain | |
from pydantic import BaseModel | |
from fastapi.staticfiles import StaticFiles | |
class Body(BaseModel): | |
subject: str | |
app = FastAPI() | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=["*"], | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
async def generate_questions(body: Body): | |
subject = body.subject | |
query = f"Quero que você gere questões de biologia, sendo do assunto: {subject}." | |
res = rag_chain.invoke(f"""{query}""") | |
return res | |
app.mount("/", StaticFiles(directory="static", html=True), name="static") | |
if __name__ == "__main__": | |
import uvicorn | |
uvicorn.run("app:app", host="0.0.0.0", port=8000) | |