Toggle Menu
Prev Up Next

# `langchain_community.document_transformers.doctran_text_translate`.DoctranTextTranslator

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

  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) | Asynchronously transform a list of documents.
  `transform_documents`(documents, **kwargs) | Translates text documents using doctran.

  __init__(openai_api_key: Optional[str] = None, language: str = 'english', openai_api_model: Optional[str] = None) → None
    Parameters

      - openai_api_key (Optional[str]) –

      - language (str) –

      - openai_api_model (Optional[str]) –

    Return type

      None

  async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]

    Asynchronously transform a list of documents.

    Parameters

      - documents (Sequence[Document]) – A sequence of Documents to be transformed.

      - kwargs (Any) –

    Returns

      A list of transformed Documents.

    Return type

      Sequence[Document]

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

    Translates text documents using doctran.

    Parameters

      - documents (Sequence[Document]) –

      - kwargs (Any) –

    Return type

      Sequence[Document]

# Examples using DoctranTextTranslator

- doctran_translate_document.md