How do i stop gpt 3.5 finishing asked question

Everytime i ask a question in gpt api, for 3.5 turbo, the model is finishing the asked question, sometimes with a word or punctuation and then answering the asked question. How do i stop this?

Welcome to the forum.

Can you share you system and initial user message you’re sending?

Hi Paul,

it can be any message not just any particular one, for example, if I ask “can you help”, the AI will respond with, “me?” and then it will answer. and at times, it will spit out the prompt or parts of the prompt instead of answering, and this is for when I test development, so issues occurring when using with api

Are you using GPT-3.5-turbo or the new -instruct version of it?

What endpoint are you using?

3.5 turbo, using json testing on local host

Can you share your exact system and user messages?

Thanks.

Go to the API playground and create a system message and a user question. Receive the correct response.

Press the “view code” button and get an example of the settings.

import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
    {
      "role": "system",
      "content": "You are an AI assistant."
    },
    {
      "role": "user",
      "content": "can you help"
    }
  ],
  temperature=0.5,
  max_tokens=256,
  top_p=0.5,
)
print(response)