from fastapi import FastAPI, Request, Form from fastapi.responses import HTMLResponse from pydantic import BaseModel import yaml from model.llama3 import LLaMA3 # ---------------- 설정 로드 ---------------- with open("config/llama3.yaml", "r") as f: config = yaml.safe_load(f) # ---------------- 모델 초기화 ---------------- llama3 = LLaMA3(config) # ---------------- FastAPI 앱 ---------------- app = FastAPI( title="Korean Pronunciation Correction API", description="FastAPI + LLaMA3 기반 발음 교정 서버", version="1.0.0" ) # ---------------- 입력 모델 ---------------- class InputData(BaseModel): user_input: str correct_input: str # ---------------- API: JSON POST ---------------- @app.post("/generate") async def generate_correction(data: InputData): result = llama3.generate(data.user_input, data.correct_input) return {"result": result} # ---------------- HTML UI ---------------- @app.get("/", response_class=HTMLResponse) async def form_ui(): return """
오류 메시지:
{str(e)}
에러 상세:
{error_details}
입력된 발음: {user_input}
정답 발음: {correct_input}
{result}