deepl.py


Overview

deepl.py defines a DeepL translation component integrated into the InfiniFlow agent framework. It provides functionality to translate text from a specified source language to a target language using the DeepL API. The file contains two main classes:

This module acts as a bridge between the InfiniFlow system’s component architecture and the external DeepL translation service, enabling multilingual translation capabilities within workflows or pipelines managed by InfiniFlow.


Detailed Documentation

Class: DeepLParam

Defines the configuration parameters necessary for the DeepL translation component.

Attributes

Methods

Usage Example

param = DeepLParam()
param.auth_key = "your_valid_deepl_auth_key"
param.source_lang = "EN"
param.target_lang = "FR"
param.check()  # Raises error if invalid

Class: DeepL

The main translation component class that interfaces with the DeepL API.

Inherits from:

Class Attributes

Methods

Usage Example

deepl_component = DeepL()
deepl_component._param.auth_key = "your_deepl_api_key"
deepl_component._param.source_lang = "EN"
deepl_component._param.target_lang = "DE"

# Mock input setup (depends on ComponentBase implementation)
deepl_component.set_input({"content": ["Hello world", "How are you?"]})

result = deepl_component._run(None)
print(result)  # Should print translated text in German

Implementation Details and Algorithms


Interaction with Other System Components


Mermaid Class Diagram

classDiagram
    class DeepLParam {
        -auth_key: str
        -parameters: list
        -source_lang: str
        -target_lang: str
        +__init__()
        +check()
    }

    class DeepL {
        +component_name: str
        +_run(history, **kwargs)
    }

    DeepLParam <|-- ComponentParamBase
    DeepL --|> ComponentBase
    DeepL --|> ABC

Summary

deepl.py provides a reusable, parameterized DeepL translation component for the InfiniFlow system. It encapsulates configuration validation, API interaction, and error handling within an easy-to-integrate class structure. This module enables automated translation tasks within larger workflows, leveraging DeepL’s powerful language translation capabilities.