Initial commit for FastAPI project
This commit is contained in:
commit
6aef310364
|
|
@ -0,0 +1,6 @@
|
|||
bin/
|
||||
include/
|
||||
lib/
|
||||
lib64/
|
||||
share/
|
||||
pyvenv.cfg
|
||||
|
|
@ -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}
|
||||
Loading…
Reference in New Issue