While writing my most recent book, “Power Platform and the AI Revolution,” I was working on interacting with ChatGPT. While working with the API is pretty well documented on the OpenAI website, I thought I’d post a quick note (more for my reference than anything else) to show how the body request is structured.
In this example, I’m sending two Power Automate trigger values into the request:
{
"model": "gpt-4",
"messages": [
{
"role": "assistant",
"content": "You are a system architect collaborating with an account executive on a statement of work for a new customer."
},
{
"role": "user",
"content": "Generate an executive summary for the included content. Focus on the following areas of the document: @{triggerBody()?['text']} Exclude the following sections from the executive summary: @{triggerBody()?['text_1']} Use the following additional information to write a compelling closing statement: @{triggerBody()?['text_2']} The completed executive summary should be between 225 and 350 words."
}
],
"max_tokens": 5000,
"temperature": 0,
"n": 1,
"stream": false,
"logprobs": null,
"stop": null
}
The first role is the role that the system plays (in this case, assistant, while the second role (user) is the how the text that the user/customer submits is treated.
