Skip to content

v1.0.0

Compare
Choose a tag to compare
@tyanas tyanas released this 01 Mar 06:04
· 31 commits to master since this release

Translate via async now is a default behavior.

The default response format differs now

client.ai.text.translate
    .fulfill({ text: "How's it going?", to: 'es' })
    .then(console.log)

The response contains the translated text, service information, and meta-information (i.e., detected language):

{
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "done": true,
    "response": [
        {
            "results": [
                "¿Cómo va todo?"
            ],
            "meta": {
                "detected_source_language": [
                    "en"
                ]
            },
            "service": {
                "provider": {
                    "id": "ai.text.translate.deepl.api",
                    "name": "DeepL API",
                    "vendor": "DeepL",
                    "description": "API",
                    "logo": "https://inten.to/static/img/api/deepl_translate.png"
                }
            }
        }
    ],
    "meta": {
        // information about initial request
    },
    "error": null
}

To get the old behavior set async: false

client.ai.text.translate
    .fulfill({ text: "How's it going?", to: 'es' , async: false })
    .then(console.log)
{
    "results": [
        "¿Cómo va todo?"
    ],
    "meta": {
        "detected_source_language": [
            "en"
        ],
        "timing": {
            "total": 0.391781,
            "providers": 0.356072
        },
        "routing": {
            "id": "best"
        }
    },
    "service": {
        "provider": {
            "id": "ai.text.translate.deepl.api",
            "name": "DeepL API",
            "timing": {
                "provider": 0.356072
            }
        }
    }
}

To use async mode but get the operation id set awaitAsync: false

client.ai.text.translate
    .fulfill({ text: "How's it going?", to: 'es' , awaitAsync: false })
    .then(console.log)
{
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}