MCPcopy Index your code
hub / github.com/PDFMathTranslate/PDFMathTranslate / translate_task

Function translate_task

pdf2zh/backend.py:39–54  ·  view source on GitHub ↗
(
    self: Task,
    stream: bytes,
    args: dict,
)

Source from the content-addressed store, hash-verified

37
38@celery_app.task(bind=True)
39def translate_task(
40 self: Task,
41 stream: bytes,
42 args: dict,
43):
44 def progress_bar(t: tqdm.tqdm):
45 self.update_state(state="PROGRESS", meta={"n": t.n, "total": t.total}) # noqa
46 print(f"Translating {t.n} / {t.total} pages")
47
48 doc_mono, doc_dual = translate_stream(
49 stream,
50 callback=progress_bar,
51 model=ModelInstance.value,
52 **args,
53 )
54 return doc_mono, doc_dual
55
56
57@flask_app.route("/v1/translate", methods=["POST"])

Callers

nothing calls this directly

Calls 1

translate_streamFunction · 0.90

Tested by

no test coverage detected