OpenAI Chat - Create Completion - Map Messages Error

Hey Guys,

I am getting this same error as others:

This is my messages array formed correctly from OpenAI:
[{“role”: “system”, “content”: “You are a hellpful assistant.”}]

When I run the module I get an error:

Tried this too:

[
    {"role": "system", "content": "You are a helpful assistant designed to output JSON."},
    {"role": "user", "content": "Who won the world series in 2020?"}
  ]

I don’t know what is wrong. Is it a bug with Make?

Thanks! :slight_smile:

Solved. Its a bug with the Make Module. Use the OpenAI Make an API request Module and it will work!

Not a bug

So this is not actually a bug, but the info message could be clearer that you cannot pass a JSON (string variable) into the field.

The message below the field says you have to pass in a variable of type “Array”.

Screenshot_2023-12-16_141256 (2)

If you pass in a JSON string (which is a variable of STRING type), you are not passing in a variable of type ARRAY).

The second line basically shows you the format of the array in JSON, but is misleading you to think that you can pass in that exact string as JSON.


How to create an ARRAY

To use the “Map” feature on the Messages field, here are some examples to create an ARRAY first

1. Aggregate to an array

If you select the “Target structure type” as the OpenAI “Messages” field, you can create an array of (Role/Message Content) fields, using an “Array Aggregator” module.

2. Create from JSON

If you want to manually type the array format as JSON, you can use a “Parse JSON” module, and wrap the items in an “array” variable like this


Mapping the ARRAY

Once you’ve created the array as above, you can map a single ARRAY variable into the Messages field:

Screenshot_2023-12-16_141235

If you want to learn more about Make, you can read up in the Help Center. I also recommend doing the tutorials in the Make Academy, and learn advanced skills like how to make custom apps to any API in the Make Partner Training Portal - both have certificates for successful completion.

2 Likes