My chatbot (API) doesn't take into account previous messages

My chatbot (API) doesn’t take into account previous messages. I have tried several other texts but nothing works.

My code:

{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “system”, “content”: “You are a helpful helper who follows standards.”}],
“messages”: [{“role”: “user”, “content”: “Let’s count to 10?”}],
“messages”: [{“role”: “assistant”, “content”: “Ok!”}],
“messages”: [{“role”: “user”, “content”: “I start! 1.”}],
“messages”: [{“role”: “assistant”, “content”: “2.”}],
“messages”: [{“role”: “user”, “content”: “3.”}]
}

Response (content): { "message": { "role": "assistant", "content": "Sorry, can you please provide more context or information about what you are referring to?" }, "finish_reason": "stop", "index": 0 }

The API literally does not take into account any previous message, no matter the context. But, in the standard CHAT-GPT (playground) it works.

There should only be one “messages” array that contains all of the chat messages, you have 6 different “messages” defined and each one is overwriting the previous value with an array that only contains a single message.

Example:

{
    "model": "gpt-3.5-turbo",
    "messages": [
        {"role": "system", "content": "Some context for the bot"},
        {"role": "user", "content": "User message 1"},
        {"role": "assistant", "content": "Assistant's response"},
        {"role": "user", "content": "User message 2"},
    ]
}
4 Likes