langchain.document_transformers.doctran_text_translate.DoctranTextTranslator

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

Translate text documents using doctran.

Parameters
  • openai_api_key – OpenAI API key. Can also be specified via environment variable

  • OPENAI_API_KEY.

  • language – The language to translate to.

Example


from langchain.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)

Transform a list of documents.

__init__(openai_api_key: Optional[str] = None, language: str = 'english', openai_api_model: Optional[str] = None) None[source]
async atransform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document][source]

Translates text documents using doctran.

transform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document][source]

Transform a list of documents.

Parameters

documents – A sequence of Documents to be transformed.

Returns

A list of transformed Documents.

Examples using DoctranTextTranslator