Spaces:
Sleeping
Sleeping
File size: 1,089 Bytes
c9ace58 ba9f52e c9ace58 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from agents.question_agent import suggest_questions
from agents.rag_agent import answer_question
app = FastAPI()
# --- CORS 설정 추가 ---
origins = [
"http://localhost:5173", # Vite 기본 포트
"http://127.0.0.1:5173",
"*", # 개발 단계에서는 전체 허용 가능
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# ------------------------
@app.get("/")
def read_root():
return {"message": "Welcome to the Capstone API!"}
@app.get("/health")
def health():
return {"status": "ok"}
@app.post("/suggest")
def suggest(data: dict):
print(f"📥 [POST /suggest] Request Body: {data}")
return suggest_questions(data["user_message"], data.get("user_profile", {}))
@app.post("/answer")
def answer(data: dict):
print(f"📥 [POST /answer] Request Body: {data}")
return answer_question(data["selected_question"], data.get("user_profile", {}))
|