Spaces:
Runtime error
Runtime error
File size: 1,041 Bytes
0c36a84 |
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 |
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("/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", {}))
|