Spaces:
Build error
Build error
File size: 716 Bytes
8f96dcd 688cd6a | 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 | from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from src.llama_Qwen2 import ask_qwen2
app = FastAPI()
# 보안 에러(CORS) 방지
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 실제 배포 시에는 GitLab Pages 주소만 넣는 것이 안전합니다.
allow_methods=["*"],
allow_headers=["*"],
)
class ChatRequest(BaseModel):
message: str
@app.post("/chat")
async def chat_endpoint(request: ChatRequest):
user_input = request.message
output_response = ask_qwen2(user_input)
return {"reply": output_response}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=7860) |