Files
docutranslate/docutranslate/translater/interfaces.py

21 lines
518 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from typing import runtime_checkable, Protocol, TypeVar
from docutranslate.agents import Agent
from docutranslate.ir.document import Document
T=TypeVar('T',bound=Document)
V=TypeVar('V',bound=Agent)
@runtime_checkable
class Translator(Protocol[T,V]):
"""
翻译中间文本原地替换Translator不做格式转换
"""
def translate(self, document:T) -> Document:
...
async def translate_async(self, document: T) -> Document:
...
def log(self,info:str):
...