JSON error on Power Automate To integrate Chatgpt into Teams

Hi everyone,

I come to you because I want to integrate a chatgpt on Power Automate so that in a Teams team, we can ask things.

But I have an overlay on chatgpt.

In my automation configuration, I have an error message which you will find in the screenshot below.

I can’t figure out why it tells me to put a valid JSON code.

image

Hi and welcome to the Forum!

Your body should look something as follows:

{
“model”: “Model name”,
“messages”: [

{
“role”: “system”,
“content”: “%System instruction%”
},
{
“role”: “user”,

“content”: “%Body content%”
}
],
“max_tokens”: 2000,
“temperature”: 0,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“top_p”: 0.95,
“stop”: null }

You can leave out the system instructions if not needed in your case and of course you can adjust the other parameters as needed.

Hi @jr.2509

What is
“role”: “system”,
“content”: “%System instruction%”

And where can I find the model? In my configuration system?

Regarding the role, if I have 100 users what can I put?
I leave it as default: Users?

Thank you for your replay !

Sorry - I typed too fast, for davinci it is actually as follows:

{
“model”: “text-davinci-003”,
“prompt”: “Your prompt”,
“temperature”: 0,
“max_tokens”: 500,
“top_p”: 0.95,
“frequency_penalty”: 0,
“presence_penalty”: 0
}

However, davinci-003 is no longer available and thus you’d have to revert to an alternative model, such as GPT-3.5-turbo-instruct. I am double checking the latest schema for instruct and will get back to you.

I am not sure I fully understand your other questions. Could you please clarify?

So, if you want to use the GPT-3.5-turbo-instruct model, which is a replacement for davinci models, this would be the JSON schema to follow, which is essentially identical to the former schema for davinci (note: I’ve simplified the list of parameters, you can add back others as you wish):

{
“model”: “gpt-3.5-turbo-instruct”,
“prompt”: “Replace with your prompt”,
“max_tokens”: 100,
“temperature”: 0
}

The endpoint to use is the following:
https://api.openai.com/v1/completions

Hey @jr.2509

If we use GPT4? can you give me the model ?

Now I have this error :
image

Sure, it would be as follows:

{
“model”: “gpt-4”,
“messages”: [
{
“role”: “system”,
“content”: “System instruction”
},
{
“role”: “user”,
“content”: “User message”
}
],
“max_tokens”: 2000,
“temperature”: 0,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“top_p”: 0.95,
“stop”: null
}

If you’d like to skip the system instructions, then use the following:

{
“model”: “gpt-4”,
“messages”: [
{
“role”: “user”,
“content”: “User message”
}
],
“max_tokens”: 2000,
“temperature”: 0,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“top_p”: 0.95,
“stop”: null
}

Also, for GPT-4 make sure to use the following endpoint:
https://api.openai.com/v1/chat/completions

I modify the body, but I get this error :frowning:

image

The body of your message should not repeat the headers.

I delete it now, but now I have the same issue : “Enter à Valid JSON” …

Check that you use the right quotation marks. When pasting the JSON schema here, they slightly changed. It should look as follows:

image

In case you are familiar with Postman, then I’d recommend that you check your JSON body there as well.

https://www.postman.com/