Internal ChatGPT API/ body construction

Has anyone had any luck creating JSON structure for "role":"system","content": "xyz" for ChatGPT? My company is utilizing an internal tool for which I have API connection details for. But I am having trouble getting the body put together correctly. I know this is a skill issue on my part but every time I try to get JSON together for HTTP requests, I feel like I am putting a jigsaw puzzle together.

Unfortunately, because it is internal, it doesn't look like I can use the ASK API action.

For the below, what portion would be the column name before the JSON construct action is applied? Like does the column name need to be "role":"system:","content" and then the text value with the system message as the value in the cell? I keep getting almost correctly formatted structures each time I try something new but it is never quite right and doesn't pass validation.

Anyone else had any success and could provide some pointers on how to structure?
{
"messages":[
{
"role":"system",
"content":"abc"
},
{
"role":"user",
"content":"abc"
}
]
}

hi @Perk

You likely don't need the hand-built JSON at all.

If I'm not missing something, and judging by the body you pasted, it's the standard OpenAI chat completion format - messages with a "role" field.

our "Ask AI" action and the OpenAI-compatible connector are designed for endpoints that adhere to that format. So if you create a new OpenAI Compatible connector (not the ChatGPT one), set up your base URL, key, and model *those you should know beforehand) it should work out of the box.

The system prompt you can set in the "Ask AI" action.

Hi Olysak,

Thank you kindly for the swift reply sir.

I have to send headers with the request like can be seen in the image below. My company requires an sid,env,apikey and emp number be sent with the request

In the Ask AI action, it does not look like I can setup headers in addition to the API key. And it looks like I can't link it to already existing web location connector where I could build these out.

Though I still think it would be neat to be able to have a bit more flexibility with the Ask AI action (assuming I am actually correct about not being able to send headers with it), I was able to figure out how to structure my JSON for a ChatGPT style request in my case.

Anyone else who may be interested (and I don't know that this is the most elegant method).

Start with your input. I am using a list of Japanese words I would like to translate into English. Use the enumerate rows action to create a key for yourself if you don't already have one.

Derive your table into two separate tables and create role/content columns in each. For the system role set your content value via an expression/parameter or whatever. Then for the user role, you will likely have your content structured from your base data or through some other means/expression etc.

Derive your system role table and append the user role table to it. Then sort by your key so that the system/user roles are oriented vertically by the key.

It will look like this.

Now use the construct JSON with the mode Object per row, array from objects. If you group by your key, you should get a JSON body conducive to ChatGPT style messaging.