Spaces:
Runtime error
Runtime error
| 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=["*"], | |
| ) | |
| # ------------------------ | |
| def health(): | |
| return {"status": "ok"} | |
| def suggest(data: dict): | |
| print(f"๐ฅ [POST /suggest] Request Body: {data}") | |
| return suggest_questions(data["user_message"], data.get("user_profile", {})) | |
| def answer(data: dict): | |
| print(f"๐ฅ [POST /answer] Request Body: {data}") | |
| return answer_question(data["selected_question"], data.get("user_profile", {})) | |