Initial commit for FastAPI project

This commit is contained in:
Esxi_Synology_Codeserver 2024-09-12 14:43:35 +09:00
commit 6aef310364
4 changed files with 22 additions and 0 deletions

6
.gitignore vendored Executable file
View File

@ -0,0 +1,6 @@
bin/
include/
lib/
lib64/
share/
pyvenv.cfg

0
README.md Executable file
View File

1
lib64 Symbolic link
View File

@ -0,0 +1 @@
lib

15
server.py Executable file
View File

@ -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}