Translation Tasks with Flow XO and ChatGPT

ChatGPT and similar AI models are rapidly adding an element of magic to nearly every technology use case you can think of. One reason for that is because it is so flexible - although at its core it is just a statistical text prediction algorithm, it can be used for everything from writing poems, to classifying text and detecting user intent from inputs, to summarizing text. It also happens to be quite good at translation tasks - detecting the language of user input and translating text from one language to another.

Our Flow XO Open AI integration exposes the raw ChatGPT API, of course, but we also built a few bonus tasks that take some of the headache out of writing custom prompts for common needs, like those specified above. In this article, we'll show you how to use the Language Detection and Translation task to work with user inputs and outputs in different language.

To follow along, install the sample flow here:

Our Open AI integration exposes one task that can handle both language detection and language translation. It looks like this:

It is a simple task, but powerful. You simply provide the input text, a target language, and you can do both language detection and language translation.

When the step runs, it will 

1. Detect the language of the input text

2. Translate the input text into the target language

Here's what our sample looks like:

Here's what a conversation with this sample looks like:

The implementation is simple. 

1. Detect the language of the input, and translate it to the language you are using (English in my case):

2. Ask for a response, in your native language 

3. Translate that response into the language detected from step 1

4. Send the output to the chat:

Easy as pie! Here is what the output of the translation step looks like in the interaction log:

As you can see, you have access to the incoming language code and name, as well as the translation. 

Happy flowing!

The Flow XO Team

Still need help? Contact Us Contact Us