# GPT

{% hint style="info" %}
:warning: This task is currently only available in the on-premise and open-source editions but not in the cloud version
{% endhint %}

"GPT" is a task that allows you to enrich or transform your data with AI using OpenAI's [chat completion](https://platform.openai.com/docs/guides/chat-completions) models.

### Usage

For example, you have such a pipeline consisting of two tasks:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FWYnjmHLyA4gKdq8Dg9Ry%2FScreenshot%202024-07-26%20at%2000.14.42.png?alt=media&#x26;token=703a256c-8058-4255-9452-a804d6667008" alt=""><figcaption></figcaption></figure>

The first task returns a JSON with the list of items, containing an item ID and amount:

```json
[
    {
        "id": 1,
        "amount": 33
    },
    {
        "id": 2,
        "amount": 150
    },
    {
        "id": 3,
        "amount": 4000
    }
]
```

Now you can ask chat GPT to transform this data. For example, multiply all amounts by 3:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2F9NTFjr1pzPOSRuHTtUN0%2FScreenshot%202024-07-26%20at%2000.13.21.png?alt=media&#x26;token=22ee74b0-eb10-41b3-a5a3-ad7cb2804232" alt=""><figcaption></figcaption></figure>

And this is what the task returns:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FIqySQ7AGVIAs4Y4dTKUS%2FScreenshot%202024-07-26%20at%2000.12.56.png?alt=media&#x26;token=110e6cf9-91d9-4d44-9e41-bd4a365d7f37" alt=""><figcaption></figcaption></figure>

Of course, such a simple multiplication can be done by other tasks without the use of AI, but that's just an example and you can use ChatGPT for much more. Some other ideas:

* Generate missing postal codes for the list of addresses
* Clean up organization names in the list
* Convert amounts from one currency to another
* Rewrite texts on the fly
* And so on and so on

For example, if you have a list of addresses missing postal codes like this:

```json
[
  {
    "country": "United States",
    "state": "Michigan",
    "city": "Detroit",
    "address": "2645 Woodward Ave"
  },
  {
    "country": "Canada",
    "province": "Alberta",
    "city": "Edmonton",
    "address": "104 Ave NW"
  },
  {
    "country": "United States",
    "state": "Florida",
    "city": "Sunrise",
    "address": "1 Panther Pkwy"
  }
]
```

With the workflow as above and that message to chat GPT:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2F9HGpjja7glsgzez9I36T%2FScreenshot%202024-07-26%20at%2000.47.48.png?alt=media&#x26;token=6b02eae8-14ef-43e9-aa95-384025526e17" alt=""><figcaption></figcaption></figure>

You will get the perfect result;

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FTzCoDozD2Z9XEzm3m9az%2FScreenshot%202024-07-26%20at%2000.47.25.png?alt=media&#x26;token=7c5d6261-1850-446c-aae7-c74a156c467d" alt=""><figcaption></figcaption></figure>

### Configuration

To be able to use this task, you need to configure your API Secret Key and choose a model you want to use:

```bash
TASK_RUNNER_OPENAI_GPT_KEY=%%YOUR_KEY_IS_HERE%%
TASK_RUNNER_OPENAI_MODEL=gpt-4o-mini
```

The following two variables need to be placed in the file `./processor/taskrunner/.env`.

Read more about [API Keys](https://platform.openai.com/api-keys) and [available models](https://platform.openai.com/docs/models) in the official OpenAI reference guide.
