Prompt and Context best practices with API

I’m trying to simulate a ChatGPT session using the API.

I’m saving a JSON array in my database with:

{ “role”: “system”, “content”:“You are a yadda yadda” }

and then multiple user content dicts based on what the user asked ChatGPT and what it returned:

{ “role”: “user”, “content”: “prompt” }
{ “role”: “user”, “content”: "chatgpt returned " }

I append the most recent prompt to the end of this array and send it to ChatGPT as part of messages to trigger the next response.

Is this the best way to do this or should I be appending what ChatGPT returns with a different role? Also is there a discernable difference between doing it this way vs. just storing the prompt string (which grows over time) and sending over a single user/content prompt with that prompt string?

thanks!

That should be assistant, I believe.

Try it and see if you get better results - you should!

Let us know if not.

Welcome to the forum. Hope you stick around. We’ve got a great dev community garden growing here!

That worked! Better responses already. Thank you.

What’s the best way to pass this type of context to the image API.

The image prompt as far as I can tell doesn’t have system, user, or assistant messages. It just takes in a string.

1 Like

No problem. Wealth of information here on dalle3 (including AMA from DALLE team…) However, you can’t really replicate the “seeds” and what-not in ChatGPT DALLE with API … not yet anyway. I’m sure it’ll get better.

I’m pretty sure all you can do is ask a single question about an image. You can’t have a whole conversation about an image, afaik.

1 Like