DoctranTextTranslator#

class langchain_community.document_transformers.doctran_text_translate.DoctranTextTranslator(openai_api_key: str | None = None, language: str = 'english', openai_api_model: str | None = None)[source]#

Translate text documents using doctran.

Parameters:
  • openai_api_key (Optional[str]) – OpenAI API key. Can also be specified via environment variable

  • OPENAI_API_KEY. –

  • language (str) – The language to translate to.

  • openai_api_model (Optional[str]) –

Example


from langchain_community.document_transformers import DoctranTextTranslator

# Pass in openai_api_key or set env var OPENAI_API_KEY qa_translator = DoctranTextTranslator(language=”spanish”) translated_document = await qa_translator.atransform_documents(documents)

Methods

__init__([openai_api_key,Β language,Β ...])

atransform_documents(documents,Β **kwargs)

Translates text documents using doctran.

transform_documents(documents,Β **kwargs)

Translates text documents using doctran.

__init__(openai_api_key: str | None = None, language: str = 'english', openai_api_model: str | None = None) β†’ None[source]#
Parameters:
  • openai_api_key (str | None) –

  • language (str) –

  • openai_api_model (str | None) –

Return type:

None

async atransform_documents(documents: Sequence[Document], **kwargs: Any) β†’ Sequence[Document][source]#

Translates text documents using doctran.

Parameters:
  • documents (Sequence[Document]) –

  • kwargs (Any) –

Return type:

Sequence[Document]

transform_documents(documents: Sequence[Document], **kwargs: Any) β†’ Sequence[Document][source]#

Translates text documents using doctran.

Parameters:
  • documents (Sequence[Document]) –

  • kwargs (Any) –

Return type:

Sequence[Document]

Examples using DoctranTextTranslator