commit 6aef310364b9222fdd7d0b3bc9b9476419093d1e Author: Esxi_Synology_Codeserver Date: Thu Sep 12 14:43:35 2024 +0900 Initial commit for FastAPI project diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..7947543 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +bin/ +include/ +lib/ +lib64/ +share/ +pyvenv.cfg diff --git a/README.md b/README.md new file mode 100755 index 0000000..e69de29 diff --git a/lib64 b/lib64 new file mode 120000 index 0000000..7951405 --- /dev/null +++ b/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/server.py b/server.py new file mode 100755 index 0000000..8949525 --- /dev/null +++ b/server.py @@ -0,0 +1,15 @@ +# server.py +from fastapi import FastAPI, Request +from paddlenlp import Taskflow + +app = FastAPI() + +# 모델 로드 (ChatGLM 등 대형 모델) +machine_translation = Taskflow("text2text_generation", source_lang="zh", target_lang="ko") + +@app.post("/translate") +async def translate(request: Request): + body = await request.json() + text = body["text"] + result = machine_translation(text) + return {"translated_text": result}